Skip to content

Commit 550fd84

Browse files
committed
Load only first 100 websites for summary statistics
1 parent a1e66df commit 550fd84

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/components/TabList.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
:item="getItem(tab)"
1919
:summaryTimeForWholeDay="summaryTime"
2020
/>
21+
22+
<div class="show-all" v-if="showOnlyFirst100Items">
23+
<button @click="showAllWebSites()">Show all websites</button>
24+
</div>
2125
</div>
2226
</template>
2327

@@ -48,6 +52,7 @@ const props = defineProps<{
4852
4953
const isShowOverallStats = computed(() => props.showAllStats && props.type == TypeOfList.All);
5054
55+
let loadedTabs: Tab[] = [];
5156
const tabs = ref<Tab[]>();
5257
const dataForOvarallStats = ref<OverallStats>();
5358
@@ -60,6 +65,13 @@ const countOfActiveDays = ref<number>();
6065
6166
const countOfSites = computed(() => (tabs.value != undefined ? tabs.value.length : 0));
6267
68+
const showOnlyFirst100Items = ref<boolean>();
69+
70+
function showAllWebSites() {
71+
showOnlyFirst100Items.value = false;
72+
tabs.value = loadedTabs;
73+
}
74+
6375
async function loadList(sortingBy: SortingBy) {
6476
let tabSummary = null;
6577
if (props.type == TypeOfList.Today) tabSummary = await useTodayTabListSummary(sortingBy);
@@ -71,10 +83,16 @@ async function loadList(sortingBy: SortingBy) {
7183
}
7284
7385
if (tabSummary != null) {
86+
loadedTabs = tabSummary.tabs;
7487
tabs.value = tabSummary.tabs;
7588
summaryTime.value = tabSummary.summaryTime;
7689
timeForChart.value = tabSummary.chart.timeForChart;
7790
sitesForChart.value = tabSummary.chart.sitesForChart;
91+
92+
if (props.type == TypeOfList.All && loadedTabs.length > 100) {
93+
showOnlyFirst100Items.value = true;
94+
tabs.value = tabSummary.tabs.slice(0, 100);
95+
} else showOnlyFirst100Items.value = false;
7896
}
7997
}
8098
@@ -108,3 +126,19 @@ onMounted(async () => {
108126
await loadList(SortingBy.UsageTime);
109127
});
110128
</script>
129+
130+
<style scoped>
131+
.show-all {
132+
text-align: center;
133+
padding-bottom: 10px;
134+
}
135+
136+
.show-all button {
137+
background-color: aliceblue;
138+
border-radius: 5px;
139+
border: 1px rgb(202, 202, 202) solid;
140+
font-size: 13px;
141+
cursor: pointer;
142+
padding: 5px 25px;
143+
}
144+
</style>

0 commit comments

Comments
 (0)