Skip to content

Commit f6a9ff3

Browse files
committed
Badge for domain list if site has limit
1 parent 40754b2 commit f6a9ff3

File tree

8 files changed

+81
-25
lines changed

8 files changed

+81
-25
lines changed

src/components/BadgeIcons.vue

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div class="d-inline-block">
3+
<span v-if="showDocumentBadge" class="badge-document">Document</span>
4+
<span v-if="showLimitBadge" class="badge-block">Limit</span>
5+
</div>
6+
</template>
7+
8+
<script lang="ts">
9+
export default {
10+
name: 'BadgeIcons',
11+
};
12+
</script>
13+
14+
<script lang="ts" setup>
15+
import { computed, onMounted, ref } from 'vue';
16+
import { TypeOfList, TypeOfUrl } from '../utils/enums';
17+
import { isDomainInLimits } from '../compositions/limit-list';
18+
19+
const props = defineProps<{
20+
url: string;
21+
type: TypeOfUrl;
22+
listType: TypeOfList;
23+
}>();
24+
25+
onMounted(async () => {
26+
isLimit.value = await isDomainInLimits(props.url);
27+
});
28+
29+
const isLimit = ref<boolean>();
30+
31+
const showDocumentBadge = computed(() => props.type == TypeOfUrl.Document);
32+
const showLimitBadge = computed(() => props.listType == TypeOfList.Today && isLimit.value == true);
33+
</script>
34+
35+
<style scoped>
36+
span.badge-document {
37+
border-radius: 6px;
38+
background-color: #0043ff9e;
39+
padding: 3px 7px;
40+
font-size: 11px;
41+
color: white;
42+
font-weight: 600;
43+
}
44+
span.badge-block {
45+
border-radius: 6px;
46+
background-color: #ff0000c0;
47+
padding: 3px 7px;
48+
font-size: 11px;
49+
color: white;
50+
font-weight: 600;
51+
}
52+
</style>

src/components/ByDays.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
</div>
4242
<div class="stats-block block">
4343
<div class="header">Average time on selected days</div>
44-
<p>{{ convertSummaryTimeToString(tabsByDays.averageTime) }}</p>
44+
<p>{{ convertSummaryTimeToString(tabsByDays!.averageTime) }}</p>
4545
</div>
46-
<ByDaysChart :data="tabsByDays" />
46+
<ByDaysChart :data="tabsByDays!" />
4747
<div>
4848
<Expander
4949
v-for="(tabDay, i) of tabsByDays?.days"

src/components/GeneralSettings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/>
2626
<span>Allow deferring block for 5 minutes</span>
2727
<p class="description">
28-
After the site is blocked, you can postpone the blocking for 5 minutes
28+
After the site is blocked, you can postpone the blocking for 5 minutes ones
2929
</p>
3030
</label>
3131
</div>

src/components/TabItem.vue

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="first-block">
66
<div class="w-80">
77
<p class="url" @click="openUrl(item.url)">{{ url }}</p>
8-
<div class="d-inline-block" v-html="getBadgeIcon()"></div>
8+
<BadgeIcons :url="url" :type="typeOfUrl" :listType="listType" />
99
</div>
1010
<p class="text-right time">{{ summaryTimeForTab }}</p>
1111
</div>
@@ -32,20 +32,18 @@ export default {
3232
<script lang="ts" setup>
3333
import { computed, ref } from 'vue';
3434
import Favicon from './Favicon.vue';
35+
import BadgeIcons from './BadgeIcons.vue';
3536
import { convertSummaryTimeToString } from '../utils/converter';
3637
import { getPercentage } from '../utils/common';
3738
import { CurrentTabItem } from '../dto/currentTabItem';
39+
import { TypeOfList, TypeOfUrl } from '../utils/enums';
3840
3941
const props = defineProps<{
4042
item: CurrentTabItem;
4143
summaryTimeForWholeDay: number;
44+
listType: TypeOfList;
4245
}>();
4346
44-
enum TypeOfUrl {
45-
WebSite,
46-
Document,
47-
}
48-
4947
const typeOfUrl = computed(() =>
5048
props.item.url.startsWith('file:') ? TypeOfUrl.Document : TypeOfUrl.WebSite,
5149
);
@@ -75,10 +73,6 @@ function openUrl(url: string) {
7573
}
7674
7775
const showWarningMessage = ref<boolean>();
78-
79-
function getBadgeIcon() {
80-
if (typeOfUrl.value == TypeOfUrl.Document) return `<span class="badge-document">Document</span>`;
81-
}
8276
</script>
8377

8478
<style scoped>
@@ -141,14 +135,6 @@ function getBadgeIcon() {
141135
.tab-item .sessions {
142136
margin: 0 0 0 5px;
143137
}
144-
.tab-item ::v-deep span.badge-document {
145-
border-radius: 6px;
146-
background-color: #0043ff9e;
147-
padding: 3px 7px;
148-
font-size: 11px;
149-
color: white;
150-
font-weight: 600;
151-
}
152138
.tab-item .warning-message {
153139
color: grey;
154140
}

src/components/TabList.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
v-for="(tab, i) of tabs"
2121
:key="i"
2222
:item="getItem(tab)"
23+
:listType="type"
2324
:summaryTimeForWholeDay="summaryTime"
2425
/>
2526

src/compositions/limit-list.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@ export async function isLimitExceeded(url: string, tab: Tab): Promise<LimitExcee
3232
LimitTime: null,
3333
};
3434
}
35+
36+
export async function isDomainInLimits(url: string): Promise<boolean> {
37+
const limitList = (await Settings.getInstance().getSetting(
38+
StorageParams.RESTRICTION_LIST,
39+
)) as Restriction[];
40+
const array = Object.values(limitList);
41+
const item = array?.find(x => isDomainEquals(x.domain, url));
42+
return item != undefined;
43+
}

src/pages/Block.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<table>
1111
<tr>
1212
<td class="title">Limit:</td>
13-
<td>{{ limitTime }}</td>
13+
<td class="value">{{ limitTime }}</td>
1414
</tr>
1515
<tr>
1616
<td class="title">Sessions:</td>
17-
<td>{{ summaryCounter }}</td>
17+
<td class="value">{{ summaryCounter }}</td>
1818
</tr>
1919
</table>
2020
</div>
@@ -60,13 +60,13 @@ body {
6060
6161
.block-container span {
6262
font-weight: 600;
63-
font-size: 17px;
63+
font-size: 21px;
6464
}
6565
6666
.header {
6767
font-weight: 600;
6868
color: #4a4a4a;
69-
font-size: 18px !important;
69+
font-size: 19px !important;
7070
vertical-align: super;
7171
margin-left: 10px;
7272
}
@@ -87,4 +87,7 @@ table .title {
8787
width: 100px;
8888
text-align: left;
8989
}
90+
table .value {
91+
font-weight: 600;
92+
}
9093
</style>

src/utils/enums.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ export enum SettingsTab {
1616
Notifications,
1717
About,
1818
}
19+
20+
export enum TypeOfUrl {
21+
WebSite,
22+
Document,
23+
}

0 commit comments

Comments
 (0)