You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/04/04 03:42:07 UTC
[doris] branch branch-1.2-lts updated: [fix](ui) fix download txt format error (#17789)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new 8e049ebd92 [fix](ui) fix download txt format error (#17789)
8e049ebd92 is described below
commit 8e049ebd92c9481fa6205c14b01cb1162dbe3ef3
Author: Jeffrey <co...@gmail.com>
AuthorDate: Thu Mar 16 17:59:29 2023 +0800
[fix](ui) fix download txt format error (#17789)
fix download txt format error
---
ui/src/pages/query-profile/index.tsx | 10 ++++++----
ui/src/utils/utils.ts | 10 +++++++++-
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/ui/src/pages/query-profile/index.tsx b/ui/src/pages/query-profile/index.tsx
index 0f136dbfea..fa257733e8 100644
--- a/ui/src/pages/query-profile/index.tsx
+++ b/ui/src/pages/query-profile/index.tsx
@@ -23,6 +23,7 @@ import {queryProfile} from 'Src/api/api';
import Table from 'Src/components/table';
import {useHistory} from 'react-router-dom';
import {Result} from '@src/interfaces/http.interface';
+import {replaceToTxt} from 'Src/utils/utils';
const {Text, Title} = Typography;
export default function QueryProfile(params: any) {
@@ -75,12 +76,13 @@ export default function QueryProfile(params: any) {
history.push('/QueryProfile/');
}
- function download(profile) {
- const blob = new Blob([JSON.stringify(profile, null, 2)], {
- type: "text/plain"
+ function download(profile: string) {
+ const profileTxt = replaceToTxt(profile);
+ const blob = new Blob([profileTxt], {
+ type: "text/plain",
});
const tagA = document.createElement("a");
- tagA.download = `profile_${(new Date()).valueOf()}.txt`;
+ tagA.download = `profile_${new Date().valueOf()}.txt`;
tagA.style.display = "none";
tagA.href = URL.createObjectURL(blob);
document.body.appendChild(tagA);
diff --git a/ui/src/utils/utils.ts b/ui/src/utils/utils.ts
index eeb5b657f9..770987f274 100644
--- a/ui/src/utils/utils.ts
+++ b/ui/src/utils/utils.ts
@@ -84,4 +84,12 @@ function getBasePath() {
return res;
}
-export {isSuccess, getDbName, getTimeNow, getBasePath};
+function replaceToTxt(str: string) {
+ var regexpNbsp = / /g;
+ var reBr = /<\/br>/g;
+ const strNoNbsp = str.replace(regexpNbsp, " ");
+ const strNoBr = strNoNbsp.replace(reBr, "\r\n");
+ return strNoBr;
+}
+
+export {isSuccess, getDbName, getTimeNow, getBasePath, replaceToTxt};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org