33 <label class =" title link" @click =" openPage(SettingsTab.Dashboard)" >
44 {{ t('dashboard.message') }}
55 </label >
6- <!-- <Favicon :favicon="item.favicon" :type="typeOfUrl" /> -->
6+ <div class =" no-data" v-if =" isLoading" >
7+ <img height =" 55" src =" ../assets/icons/preloader.gif" />
8+ </div >
9+ <div v-else >
10+ <no-data-by-days v-if =" countOfDays == undefined || (countOfDays == 0 && !noData)" />
11+ <div v-else-if =" noData" >
12+ <div class =" no-data" >
13+ {{ t('noDataForPeriod.message') }}
14+ <VueDatePicker
15+ range
16+ :enable-time-picker =" false"
17+ class =" date-picker"
18+ v-model =" selectedDate"
19+ :preset-ranges =" presetRanges"
20+ @update:model-value =" handleDate"
21+ >
22+ <template #yearly =" { label , range , presetDateRange } " >
23+ <span @click =" presetDateRange(range)" >{{ label }}</span >
24+ </template ></VueDatePicker
25+ >
26+ </div >
27+ </div >
28+ <div v-else >
29+ <div class =" date-block" >
30+ <div >
31+ <Favicon :favicon =" tab?.favicon" :type =" getTypeOfUrl(tab?.url!)" />
32+ <span class =" title" > {{ tab?.url }}</span >
33+ </div >
34+
35+ <VueDatePicker
36+ range
37+ :enable-time-picker =" false"
38+ class =" date-picker mt-10"
39+ v-model =" selectedDate"
40+ :preset-ranges =" presetRanges"
41+ @update:model-value =" handleDate"
42+ >
43+ <template #yearly =" { label , range , presetDateRange } " >
44+ <span @click =" presetDateRange(range)" >{{ label }}</span >
45+ </template ></VueDatePicker
46+ >
47+ </div >
48+ <div class =" mt-20 ml-10 mr-10" >
49+ <ByDaysChart :data =" tabInfoByDays!" />
50+ </div >
51+ </div >
52+ </div >
753 </div >
8- <div class =" chart chartByHours" ></div >
954</template >
1055
1156<script lang="ts">
@@ -16,18 +61,63 @@ export default {
1661
1762<script lang="ts" setup>
1863import { useI18n } from ' vue-i18n' ;
19- // import Favicon from './Favicon.vue';
64+ import Favicon from ' ./Favicon.vue' ;
65+ import NoDataByDays from ' ./NoDataByDays.vue' ;
66+ import ByDaysChart from ' ../components/ByDaysChart.vue' ;
2067import { openPage } from ' ../utils/open-page' ;
21- import { onMounted , ref } from ' vue' ;
68+ import { computed , onMounted , ref } from ' vue' ;
2269import { SettingsTab } from ' ../utils/enums' ;
70+ import { ThisWeekRange , ranges } from ' ../utils/date' ;
71+ import { useDomainStatsByDays } from ' ../compositions/useDomainStatsByDays' ;
72+ import { TabListByDays } from ' ../dto/tabListSummary' ;
73+ import { Tab } from ' ../entity/tab' ;
74+ import { getTypeOfUrl } from ' ../utils/get-type-of-url' ;
75+ import { injectTabsRepository } from ' ../repository/inject-tabs-repository' ;
2376
2477const props = defineProps <{
2578 domain: string ;
2679}>();
2780
2881const { t } = useI18n ();
82+ const presetRanges = ranges ();
83+
84+ const tabInfoByDays = ref <TabListByDays >();
85+ const isLoading = ref <boolean >();
86+ const noData = ref <boolean >(false );
87+ const selectedDate = ref <Date []>();
88+ const tab = ref <Tab >();
89+
90+ const countOfDays = computed (() =>
91+ tabInfoByDays .value != undefined ? tabInfoByDays .value .days .length : 0 ,
92+ );
93+
94+ onMounted (async () => {
95+ isLoading .value = true ;
96+ selectedDate .value = ThisWeekRange ;
97+ const dateFrom = selectedDate .value ?.[0 ] as Date ;
98+ const dateTo = selectedDate .value ?.[1 ] as Date ;
99+ const repo = await injectTabsRepository ();
100+ tab .value = repo .getTab (props .domain );
101+
102+ await loadList (dateFrom , dateTo );
103+ });
29104
30- onMounted (() => {});
105+ async function loadList(dateFrom : Date , dateTo : Date ) {
106+ const tabList = await useDomainStatsByDays (dateFrom , dateTo );
107+ if (tabList != null ) {
108+ tabInfoByDays .value = tabList ;
109+ if (tabList .days .length == 0 && tabList .summaryTime == 0 ) noData .value = true ;
110+ else noData .value = false ;
111+ }
112+ isLoading .value = false ;
113+ }
114+
115+ async function handleDate(modelData : Date []) {
116+ selectedDate .value = modelData ;
117+ const dateFrom = selectedDate .value ?.[0 ] as Date ;
118+ const dateTo = selectedDate .value ?.[1 ] as Date ;
119+ await loadList (dateFrom , dateTo );
120+ }
31121 </script >
32122
33123<style scoped>
@@ -36,4 +126,8 @@ onMounted(() => {});
36126 color : grey ;
37127 text-decoration : underline ;
38128}
129+ .date-block {
130+ display : flex ;
131+ justify-content : space-between ;
132+ }
39133 </style >
0 commit comments