11<template >
2- <TabItemHeader
3- :listType =" type"
4- :summaryTime =" summaryTime"
5- :countOfSites =" countOfSites"
6- :firstDay =" firstDay"
7- />
8- <TabItem v-for =" (tab, i) of tabs" :key =" i" :tab =" tab" :summaryTime =" summaryTime" />
2+ <div class =" no-data" v-if =" countOfSites == undefined || countOfSites == 0" >No data</div >
3+ <div v-else >
4+ <DonutChart :time =" timeForChart" :labels =" sitesForChart" />
5+ <TabItemHeader
6+ :listType =" type"
7+ :summaryTime =" summaryTime"
8+ :countOfSites =" countOfSites"
9+ :firstDay =" firstDay"
10+ />
11+ <TabItem v-for =" (tab, i) of tabs" :key =" i" :tab =" tab" :summaryTime =" summaryTime" />
12+ </div >
913</template >
1014
1115<script lang="ts">
@@ -18,6 +22,7 @@ export default {
1822import { computed , onMounted , ref } from ' vue' ;
1923import TabItem from ' ../components/TabItem.vue' ;
2024import TabItemHeader from ' ../components/TabItemHeader.vue' ;
25+ import DonutChart from ' ../components/DonutChart.vue' ;
2126import { injectTabsRepository } from ' ../repository/inject-tabs-repository' ;
2227import { Tab } from ' ../entity/tab' ;
2328import { todayLocalDate } from ' ../utils/today' ;
@@ -28,30 +33,42 @@ const props = defineProps<{
2833}>();
2934
3035const tabs = ref <Tab []>();
31- const summaryTime = computed (() => {
32- const summaryTimeList = tabs .value ?.map (function (tab ) {
33- return tab .days .find (day => day .date === todayLocalDate ())! .summary ;
34- });
35- return summaryTimeList != undefined
36- ? summaryTimeList .reduce (function (a , b ) {
37- return a + b ;
38- })
39- : 0 ;
40- });
4136
42- const countOfSites = computed (() => tabs .value ?.length );
37+ const timeForChart = ref <number []>();
38+ const sitesForChart = ref <string []>();
39+
40+ const summaryTime = ref <number >();
41+
42+ const countOfSites = computed (() => (tabs .value != undefined ? tabs .value .length : 0 ));
43+
4344const firstDay = computed (() => {
4445 if (props .type == TypeOfList .All ) return ;
4546});
4647
4748onMounted (async () => {
4849 const repo = await injectTabsRepository ();
4950 let unSortedTabs = repo .getTodayTabs ();
50- tabs .value = unSortedTabs ? .sort (function (a : Tab , b : Tab ) {
51+ tabs .value = unSortedTabs .sort (function (a : Tab , b : Tab ) {
5152 return (
5253 b .days .find (s => s .date === todayLocalDate ())! .summary -
5354 a .days .find (s => s .date === todayLocalDate ())! .summary
5455 );
5556 });
57+
58+ const summaryTimeList = tabs .value ?.map (function (tab ) {
59+ return tab .days .find (day => day .date === todayLocalDate ())! .summary ;
60+ });
61+ const siteList = tabs .value ?.map (function (tab ) {
62+ return tab .url ;
63+ });
64+ timeForChart .value = summaryTimeList ?.slice (0 , 10 );
65+ sitesForChart .value = siteList ?.slice (0 , 10 );
66+
67+ summaryTime .value =
68+ summaryTimeList != undefined && summaryTimeList .length > 0
69+ ? summaryTimeList .reduce (function (a , b ) {
70+ return a + b ;
71+ })
72+ : 0 ;
5673});
5774 </script >
0 commit comments