diff --git a/public/js/pages/DashboardNew/DashboardNew.css b/public/js/pages/DashboardNew/DashboardNew.css index 756e7268f..9f6a4480a 100644 --- a/public/js/pages/DashboardNew/DashboardNew.css +++ b/public/js/pages/DashboardNew/DashboardNew.css @@ -38,6 +38,12 @@ margin-top: 20px; } +.dashboard-buttons { + display: flex; + gap: 1rem; + margin-top: 20px; +} + @media (min-width: 768px) { .dashboard-cards { diff --git a/public/js/pages/DashboardNew/DashboardNew.js b/public/js/pages/DashboardNew/DashboardNew.js index 201f0f166..c08acbdda 100644 --- a/public/js/pages/DashboardNew/DashboardNew.js +++ b/public/js/pages/DashboardNew/DashboardNew.js @@ -190,6 +190,39 @@ Vue.component('tt-timeline-chart', { Vue.component('dashboard-default', { props: ['dashboardData'], + data() { + return { + selectedTimeframe: 'all', + window: window, + moment: moment + } + }, + methods: { + exportTimeline() { + // we need all timelines with "ONT installiert", "Leerrohr", "Bestellungen" + const data = this.dashboardData.timeline[0].map((item, index) => ({ + date: item.date, + bestellungen: item.value, + leerrohr: this.dashboardData.timeline_leerrohr[0][index].value, + ont_installiert: this.dashboardData.timeline_ont_installed[0][index].value + })); + + // dont use any library for the csv + const csv = [ + ['Datum', 'Bestellungen', 'Leerrohr', 'ONT installiert'], + ...data.map(item => [item.date, item.bestellungen, item.leerrohr, item.ont_installiert]) + ].map(row => row.join(',')).join('\n'); + + const blob = new Blob([csv], {type: 'text/csv'}); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + + a.href = url; + a.download = 'timeline.csv'; + a.click(); + URL.revokeObjectURL(url); + } + }, template: `