@@ -118,9 +159,6 @@ export default function StatementsOverview() {
setQueryOptions({ ...queryOptions, searchText })
}
/>
-
@@ -142,9 +180,6 @@ export default function StatementsOverview() {
}
/>
)}
-
- setShowSettings(true)} />
-
{loadingStatements ? (
@@ -152,6 +187,11 @@ export default function StatementsOverview() {
)}
+
+
+
+
+
From 858301f5e1a1cea2527c940eb5065807b971f35d Mon Sep 17 00:00:00 2001
From: baurine <2008.hbl@gmail.com>
Date: Thu, 29 Oct 2020 17:22:48 +0800
Subject: [PATCH 14/20] refine download csv experience in ui
---
ui/lib/apps/Statement/pages/List/index.tsx | 25 +++++++++++-----------
ui/lib/apps/Statement/translations/en.yaml | 3 ++-
ui/lib/apps/Statement/translations/zh.yaml | 1 +
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/ui/lib/apps/Statement/pages/List/index.tsx b/ui/lib/apps/Statement/pages/List/index.tsx
index fde85d6dfe..cf883223f0 100644
--- a/ui/lib/apps/Statement/pages/List/index.tsx
+++ b/ui/lib/apps/Statement/pages/List/index.tsx
@@ -10,7 +10,6 @@ import {
Dropdown,
Menu,
message,
- Modal,
} from 'antd'
import { useLocalStorageState } from '@umijs/hooks'
import {
@@ -36,6 +35,12 @@ const { Search } = Input
const STMT_VISIBLE_COLUMN_KEYS = 'statement.visible_column_keys'
const STMT_SHOW_FULL_SQL = 'statement.show_full_sql'
+function downloadByLink(url: string) {
+ const downloadLink = document.createElement('a')
+ downloadLink.href = url
+ downloadLink.click()
+}
+
export default function StatementsOverview() {
const { t } = useTranslation()
@@ -66,18 +71,13 @@ export default function StatementsOverview() {
} = controller
async function exportCSV() {
- message.info('exporting...', 1)
+ message.info(t('statement.pages.overview.toolbar.exporting') + '...', 2)
const token = await getDownloadToken()
if (token) {
const url = `${client.getBasePath()}/statements/download?token=${token}`
- Modal.success({
- title: 'Export finished',
- okText: 'Download',
- onOk: () => {
- window.open(url)
- return Promise.resolve('')
- },
- })
+ // `window.open(url)` would cause browser popup interception if getDownloadToken takes long time
+ // window.open(url)
+ downloadByLink(url)
}
}
@@ -96,8 +96,9 @@ export default function StatementsOverview() {
)
diff --git a/ui/lib/apps/Statement/translations/en.yaml b/ui/lib/apps/Statement/translations/en.yaml
index 3f9f6b3179..030c4d1e21 100644
--- a/ui/lib/apps/Statement/translations/en.yaml
+++ b/ui/lib/apps/Statement/translations/en.yaml
@@ -37,7 +37,8 @@ statement:
recent: Recent
usual_time_ranges: Common
custom_time_ranges: Custom
- export: export
+ export: Export
+ exporting: Exporting
settings:
title: Settings
disabled_result:
diff --git a/ui/lib/apps/Statement/translations/zh.yaml b/ui/lib/apps/Statement/translations/zh.yaml
index 61101a1a01..e2b5045a13 100644
--- a/ui/lib/apps/Statement/translations/zh.yaml
+++ b/ui/lib/apps/Statement/translations/zh.yaml
@@ -38,6 +38,7 @@ statement:
usual_time_ranges: 常用时间范围
custom_time_ranges: 自定义时间范围
export: 导出
+ exporting: 正在导出
settings:
title: 设置
disabled_result:
From c29ea221f206fc90dea3cc47616ffda01a6991b6 Mon Sep 17 00:00:00 2001
From: baurine <2008.hbl@gmail.com>
Date: Thu, 29 Oct 2020 17:25:51 +0800
Subject: [PATCH 15/20] rename getDownloadToken to genDownloadToken
---
ui/lib/apps/Statement/pages/List/index.tsx | 6 +++---
ui/lib/apps/Statement/utils/useStatementTableController.ts | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ui/lib/apps/Statement/pages/List/index.tsx b/ui/lib/apps/Statement/pages/List/index.tsx
index cf883223f0..8787646f42 100644
--- a/ui/lib/apps/Statement/pages/List/index.tsx
+++ b/ui/lib/apps/Statement/pages/List/index.tsx
@@ -66,16 +66,16 @@ export default function StatementsOverview() {
loadingStatements,
tableColumns,
- getDownloadToken,
+ genDownloadToken,
downloading,
} = controller
async function exportCSV() {
message.info(t('statement.pages.overview.toolbar.exporting') + '...', 2)
- const token = await getDownloadToken()
+ const token = await genDownloadToken()
if (token) {
const url = `${client.getBasePath()}/statements/download?token=${token}`
- // `window.open(url)` would cause browser popup interception if getDownloadToken takes long time
+ // `window.open(url)` would cause browser popup interception if genDownloadToken takes long time
// window.open(url)
downloadByLink(url)
}
diff --git a/ui/lib/apps/Statement/utils/useStatementTableController.ts b/ui/lib/apps/Statement/utils/useStatementTableController.ts
index e47fb9827f..0d854dc4fb 100644
--- a/ui/lib/apps/Statement/utils/useStatementTableController.ts
+++ b/ui/lib/apps/Statement/utils/useStatementTableController.ts
@@ -68,7 +68,7 @@ export interface IStatementTableController {
tableColumns: IColumn[]
visibleColumnKeys: IColumnKeys
- getDownloadToken: () => Promise
+ genDownloadToken: () => Promise
downloading: boolean
}
@@ -222,7 +222,7 @@ export default function useStatementTableController(
}, [queryOptions, allTimeRanges, validTimeRange, selectedFields])
const [downloading, setDownloading] = useState(false)
- async function getDownloadToken() {
+ async function genDownloadToken() {
let token = ''
try {
setDownloading(true)
@@ -261,7 +261,7 @@ export default function useStatementTableController(
tableColumns,
visibleColumnKeys,
- getDownloadToken,
+ genDownloadToken,
downloading,
}
}
From 7d803748d25224713dd3d7084fa27f1314b38be1 Mon Sep 17 00:00:00 2001
From: baurine <2008.hbl@gmail.com>
Date: Thu, 29 Oct 2020 22:29:36 +0800
Subject: [PATCH 16/20] refine ui
---
ui/lib/apps/Statement/pages/List/index.tsx | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/ui/lib/apps/Statement/pages/List/index.tsx b/ui/lib/apps/Statement/pages/List/index.tsx
index 8787646f42..36d804fbde 100644
--- a/ui/lib/apps/Statement/pages/List/index.tsx
+++ b/ui/lib/apps/Statement/pages/List/index.tsx
@@ -16,6 +16,8 @@ import {
ReloadOutlined,
LoadingOutlined,
MenuOutlined,
+ SettingOutlined,
+ ExportOutlined,
} from '@ant-design/icons'
import { ScrollablePane } from 'office-ui-fabric-react/lib/ScrollablePane'
import { useTranslation } from 'react-i18next'
@@ -71,13 +73,17 @@ export default function StatementsOverview() {
} = controller
async function exportCSV() {
- message.info(t('statement.pages.overview.toolbar.exporting') + '...', 2)
+ const hide = message.loading(
+ t('statement.pages.overview.toolbar.exporting') + '...',
+ 0
+ )
const token = await genDownloadToken()
if (token) {
const url = `${client.getBasePath()}/statements/download?token=${token}`
// `window.open(url)` would cause browser popup interception if genDownloadToken takes long time
// window.open(url)
downloadByLink(url)
+ hide()
}
}
@@ -94,8 +100,10 @@ export default function StatementsOverview() {
const dropdownMenu = (