added new estmk export
This commit is contained in:
@@ -594,7 +594,13 @@ Vue.component('dashboard-new', {
|
||||
template: `
|
||||
<tt-card>
|
||||
<template v-slot:header>
|
||||
<h3>Akquise Statistiken</h3>
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr">
|
||||
<h3>Akquise Statistiken</h3>
|
||||
|
||||
<tt-button
|
||||
v-if="window.TT_CONFIG['IS_ADMIN'] === 'true' || window.TT_CONFIG.ME_ADDRESS_ID === '209'"
|
||||
text="Gesamt CSV Download" additional-class="btn-success" @click="csvExport" icon="fa fa-download"/>
|
||||
</div>
|
||||
</template>
|
||||
<tt-loader v-if="isLoading" style="margin: -5rem -1.5rem -1.5rem;"/>
|
||||
<div class="dashboard-new">
|
||||
@@ -617,6 +623,7 @@ Vue.component('dashboard-new', {
|
||||
`,
|
||||
data() {
|
||||
return {
|
||||
window,
|
||||
dashboardData: {
|
||||
type: 'unloaded',
|
||||
order_max_home_addrdb: 0,
|
||||
@@ -665,6 +672,24 @@ Vue.component('dashboard-new', {
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
}
|
||||
},
|
||||
async csvExport() {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
const response = await axios.get(`${window.TT_CONFIG['BASE_URL']}/export`);
|
||||
|
||||
const csvData = response.data;
|
||||
const csvContent = "data:text/csv;charset=utf-8," + [Object.keys(csvData[0]), ...csvData.map(obj => Object.keys(csvData[0]).map(header => obj[header]))].map(e => e.join(";")).join("\n"); const encodedUri = encodeURI(csvContent);
|
||||
const link = document.createElement("a");
|
||||
link.setAttribute("href", encodedUri);
|
||||
link.setAttribute("download", `Statistik_${new Date().toISOString()}.csv`);
|
||||
document.body.appendChild(link); // Required for FF
|
||||
link.click();
|
||||
} catch (error) {
|
||||
console.error('Error exporting CSV:', error);
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
Reference in New Issue
Block a user