This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new eb116cd25e [chore](ui) execute selected code in sql editor. (#16906)
eb116cd25e is described below
commit eb116cd25eb200b1d507bce98c3c531b128ba4d6
Author: ZhangYu0123 <[email protected]>
AuthorDate: Thu Feb 23 14:25:06 2023 +0800
[chore](ui) execute selected code in sql editor. (#16906)
* ui playground support selection sql to execute
* ui playground support selection sql to execute
---
ui/src/pages/logs/index.tsx | 3 ++-
ui/src/pages/playground/content/index.tsx | 14 +++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
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) {
<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>
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);
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]