diff --git a/assets/icons/csvicon.svg b/assets/icons/csvicon.svg
index 269627f..cf008ca 100644
--- a/assets/icons/csvicon.svg
+++ b/assets/icons/csvicon.svg
@@ -6,7 +6,7 @@
-
+
diff --git a/assets/icons/openappicon.svg b/assets/icons/openappicon.svg
new file mode 100644
index 0000000..eb4ab94
--- /dev/null
+++ b/assets/icons/openappicon.svg
@@ -0,0 +1,11 @@
+
+
+
diff --git a/src/components/Dashboard/common/ExportListButton.jsx b/src/components/Dashboard/common/ExportListButton.jsx
index f29d60c..e95c3dc 100644
--- a/src/components/Dashboard/common/ExportListButton.jsx
+++ b/src/components/Dashboard/common/ExportListButton.jsx
@@ -4,6 +4,8 @@ import { Button, Dropdown, Modal } from 'antd'
import ExcelIcon from '../../Icons/ExcelIcon'
import ODataIcon from '../../Icons/ODataIcon'
import CsvIcon from '../../Icons/CsvIcon'
+import DownloadIcon from '../../Icons/DownloadIcon'
+import OpenAppIcon from '../../Icons/OpenAppIcon'
import ExportIcon from '../../Icons/ExportIcon'
import ODataURL from './ODataURL'
import { ApiServerContext } from '../context/ApiServerContext'
@@ -16,7 +18,8 @@ const ExportListButton = ({
}) => {
const [odataModalOpen, setOdataModalOpen] = useState(false)
const [excelLoading, setExcelLoading] = useState(false)
- const { exportToExcel } = useContext(ApiServerContext)
+ const [csvLoading, setCsvLoading] = useState(false)
+ const { exportToExcel, exportToCsv } = useContext(ApiServerContext)
const handleExcelExport = async (mode) => {
setExcelLoading(true)
@@ -27,40 +30,48 @@ const ExportListButton = ({
}
}
+ const exportLoading = excelLoading || csvLoading
const menuItems = [
{
key: 'excel',
- label: excelLoading ? 'Exporting...' : 'Excel',
+ label: excelLoading ? 'Exporting...' : 'Microsoft Excel',
icon: ,
- disabled: excelLoading,
+ disabled: exportLoading,
children: [
{
key: 'excel-download',
- label: 'Download',
- disabled: excelLoading,
+ label: 'Download File',
+ icon: ,
+ disabled: exportLoading,
onClick: () => handleExcelExport('download')
},
{
key: 'excel-open',
label: 'Open in Excel',
- disabled: excelLoading,
+ icon: ,
+ disabled: exportLoading,
onClick: () => handleExcelExport('open')
}
]
},
{
key: 'odata',
- label: 'OData',
+ label: 'OData Connection',
icon: ,
onClick: () => setOdataModalOpen(true)
},
{
key: 'csv',
- label: 'CSV',
+ label: csvLoading ? 'Exporting...' : 'CSV File',
icon: ,
- disabled: true,
- onClick: () => {
- // TODO: implement CSV export
+ disabled: exportLoading,
+ onClick: async () => {
+ setCsvLoading(true)
+ try {
+ await exportToCsv(objectType)
+ } finally {
+ setCsvLoading(false)
+ }
}
}
]
@@ -70,12 +81,13 @@ const ExportListButton = ({
}
- disabled={disabled}
+ disabled={disabled || exportLoading}
size={size}
+ loading={exportLoading}
{...buttonProps}
/>
diff --git a/src/components/Dashboard/common/ODataURL.jsx b/src/components/Dashboard/common/ODataURL.jsx
index 4a00dae..6056ae7 100644
--- a/src/components/Dashboard/common/ODataURL.jsx
+++ b/src/components/Dashboard/common/ODataURL.jsx
@@ -13,7 +13,7 @@ const ODataURL = ({ objectType }) => {
return (
Use this URL to connect Power BI, Excel, or other OData clients. An
diff --git a/src/components/Dashboard/context/ApiServerContext.jsx b/src/components/Dashboard/context/ApiServerContext.jsx
index d4d6dd8..cc82711 100644
--- a/src/components/Dashboard/context/ApiServerContext.jsx
+++ b/src/components/Dashboard/context/ApiServerContext.jsx
@@ -915,6 +915,35 @@ const ApiServerProvider = ({ children }) => {
}
}
+ // Export list data to CSV and download
+ const exportToCsv = async (objectType) => {
+ try {
+ const response = await axios.get(
+ `${config.backendUrl}/csv/${objectType}`,
+ {
+ responseType: 'blob',
+ headers: {
+ Accept: 'text/csv',
+ Authorization: `Bearer ${token}`
+ }
+ }
+ )
+ const blob = new Blob([response.data], { type: 'text/csv' })
+ const url = URL.createObjectURL(blob)
+ const link = document.createElement('a')
+ link.href = url
+ link.download = `${objectType}-export-${new Date().toISOString().slice(0, 10)}.csv`
+ document.body.appendChild(link)
+ link.click()
+ document.body.removeChild(link)
+ URL.revokeObjectURL(url)
+ message.success('CSV file downloaded')
+ } catch (err) {
+ console.error(err)
+ showError(err, () => exportToCsv(objectType))
+ }
+ }
+
// Export list data to Excel and download or open in Excel
const exportToExcel = async (objectType, mode = 'download') => {
try {
@@ -1515,6 +1544,7 @@ const ApiServerProvider = ({ children }) => {
showError,
fetchFileContent,
exportToExcel,
+ exportToCsv,
fetchTemplatePreview,
fetchTemplatePDF,
fetchNotes,
diff --git a/src/components/Icons/OpenAppIcon.jsx b/src/components/Icons/OpenAppIcon.jsx
new file mode 100644
index 0000000..2fc7dae
--- /dev/null
+++ b/src/components/Icons/OpenAppIcon.jsx
@@ -0,0 +1,6 @@
+import Icon from '@ant-design/icons'
+import CustomIconSvg from '../../../assets/icons/openappicon.svg?react'
+
+const OpenAppIcon = (props) =>
+
+export default OpenAppIcon