3737 <span @click =" presetDateRange(range)" >{{ label }}</span >
3838 </template ></VueDatePicker
3939 >
40+ <input type =" button" value =" Export to CSV" @click =" exportToCsv()" />
4041 </div >
4142 <div class =" stats-block block" >
4243 <div class =" header" >Average time on selected days</div >
@@ -77,6 +78,8 @@ import { TabListByDays } from '../dto/tabListSummary';
7778import { useTabListByDays } from ' ../compositions/tab-list-by-days' ;
7879import { convertSummaryTimeToString } from ' ../utils/converter' ;
7980import { ranges , ThisWeekRange } from ' ../utils/date' ;
81+ import { useImportToCsvWithData } from ' ../compositions/toCsv' ;
82+ import { useFile , FileType } from ' ../compositions/loadFile' ;
8083
8184const tabsByDays = ref <TabListByDays >();
8285const isLoading = ref <boolean >();
@@ -113,6 +116,17 @@ onMounted(async () => {
113116 const dateTo = selectedDate .value ?.[1 ] as Date ;
114117 await loadList (dateFrom , dateTo );
115118});
119+
120+ async function exportToCsv() {
121+ const dateFrom = selectedDate .value ?.[0 ] as Date ;
122+ const dateTo = selectedDate .value ?.[1 ] as Date ;
123+ const csv = await useImportToCsvWithData (tabsByDays .value ?.days );
124+ useFile (
125+ csv ,
126+ FileType .CSV ,
127+ ` websites_${dateFrom .toLocaleDateString ()}-${dateTo .toLocaleDateString ()}.csv ` ,
128+ );
129+ }
116130 </script >
117131
118132<style scoped>
@@ -139,7 +153,9 @@ onMounted(async () => {
139153 color : rgb (59 , 59 , 59 );
140154}
141155.date-block {
142- margin : 0 20px 0 20px ;
156+ display : flex ;
157+ justify-content : space-between ;
158+ margin : 0 25px ;
143159}
144160.date-block .date-picker {
145161 width : 250px ;
0 commit comments