Skip to content

Commit 40754b2

Browse files
committed
Open block page iss limit exceeded
1 parent 8abbfbf commit 40754b2

File tree

13 files changed

+186
-319
lines changed

13 files changed

+186
-319
lines changed

src/assets/css/dashboard.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ body {
4545
}
4646

4747
input[type="text"]{
48-
height: 32px;
48+
height: 36px;
4949
padding: 0 0 0 5px;
5050
width: 400px;
5151
border-radius: 3px;

src/assets/css/general.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ input[type="button"]{
4949
background: #428bff;
5050
color: #fff;
5151
border-radius: 3px;
52-
height: 35px;
52+
height: 36px;
5353
line-height: 35px;
5454
padding: 0 20px;
5555
border: 0;

src/block.html

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Access to the site is limited - Web Activity Time Tracker</title>
8+
</head>
39

4-
<head>
5-
<meta charset="utf-8">
6-
<title>Access to the site is limited</title>
7-
<link href="style/block.css" rel="stylesheet" />
8-
<script src="scripts/storage.js"></script>
9-
<script src="scripts/common.js"></script>
10-
<script src="scripts/block.js"></script>
11-
</head>
10+
<body>
11+
<script type="module" src="./block.ts"></script>
12+
</body>
1213

13-
<body>
14-
<div>
15-
<img src="icons/time.svg" height="50">
16-
<p class="title">Time limit</p>
17-
<div class="description">You've reached your limit today on <span id="site" class="current-site"></span></div>
18-
<div class="description margin-top-10">Your current daily limit is <span id="limit" class="current-limit"></span></div>
19-
20-
<div class="description margin-top-10">You have already been here
21-
<span id="deferredCount" class="deferred-metrics"></span> times for a total duration of
22-
<span id="deferredTime" class="deferred-metrics"></span> today !
23-
</div>
24-
<div class="margin-top-10"><a id="deffererBtn" class="defferer-link">Set aside for 5 minutes</a></div>
25-
</div>
26-
<p class="product-title">Web Activity Time Tracker</p>
27-
</body>
28-
29-
</html>
14+
<!-- <link rel="stylesheet" href="assets/css/blocked.css" /> -->
15+
<link rel="stylesheet" href="assets/css/general.css" />
16+
</html>

src/block.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Block from './pages/Block.vue';
2+
import { createApp } from 'vue';
3+
4+
createApp(Block).mount('body');

src/components/Limits.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<template>
22
<div>
33
<p class="setting-header mt-0">Daily restrictions on access to websites:</p>
4-
<p class="descrition">
4+
<p class="description">
55
Set the maximum time allowed to visit the site per day. After this time, the site will be
66
blocked.
77
</p>
8+
<p class="description">
9+
If you set the blocking time to 0 hours 0 minutes, the website will be blocked immediately
10+
</p>
811
<ul readonly class="url-list">
912
<li v-for="(limit, i) of limitList" :key="i">
1013
<div>
@@ -21,14 +24,14 @@
2124
<div class="limits-time-block mt-20">
2225
<input
2326
type="text"
24-
class="d-inline-block height"
27+
class="d-inline-block"
2528
placeholder="Enter website name..."
2629
v-model="newWebsiteForLimitList"
2730
/>
2831
<VueDatePicker v-model="time" time-picker class="date-picker height" />
2932
<input
3033
type="button"
31-
class="d-inline-block small-btn height"
34+
class="d-inline-block small-btn"
3235
value="Add Website"
3336
:disabled="newWebsiteForLimitList == null || newWebsiteForLimitList == '' || time == null"
3437
@click="addToLimitList()"
@@ -52,7 +55,6 @@ import { isDomainEquals } from '../utils/common';
5255
import { extractHostname } from '../compositions/extract-hostname';
5356
import { Restriction } from '../entity/restriction';
5457
import { convertSecondsToHHMM } from '../utils/converter';
55-
import { Time } from '../utils/time';
5658
5759
const notification = useNotification();
5860

src/compositions/block-page.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import Browser from 'webextension-polyfill';
2+
import { buildBlockQuery } from '../utils/block-page';
23

3-
export async function useBlockPage(url: string, summaryTime: number, summaryCounter: number): Promise<void>{
4-
const blockUrl = Browser.runtime.getURL("block.html") + '?url=' + url
5-
+ '&summaryTime=' + summaryTime
6-
+ '&summaryCounter=' + summaryCounter;
7-
const tab = await Browser.tabs.query({ currentWindow: true, active: true })
8-
Browser.tabs.update(tab[0].id, { url: blockUrl });
9-
}
4+
export async function useBlockPage(
5+
url: string,
6+
summaryTime: number,
7+
summaryCounter: number,
8+
): Promise<void> {
9+
const blockUrl =
10+
Browser.runtime.getURL('src/block.html') + buildBlockQuery(url, summaryTime, summaryCounter);
11+
const tab = await Browser.tabs.query({ currentWindow: true, active: true });
12+
Browser.tabs.update(tab[0].id, { url: blockUrl });
13+
}

src/compositions/limit-list.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
import { Restriction } from '../entity/restriction';
22
import { Tab } from '../entity/tab';
33
import { StorageParams } from '../storage/storage-params';
4+
import { isDomainEquals } from '../utils/common';
45
import { todayLocalDate } from '../utils/date';
56
import { Settings } from './settings';
67

7-
export async function isLimitExceeded(url: string, tab: Tab): Promise<boolean> {
8+
export type LimitExceed = {
9+
IsLimitExceeded: boolean;
10+
LimitTime: number | null;
11+
};
12+
13+
export async function isLimitExceeded(url: string, tab: Tab): Promise<LimitExceed> {
814
const limitList = (await Settings.getInstance().getSetting(
915
StorageParams.RESTRICTION_LIST,
1016
)) as Restriction[];
1117
const array = Object.values(limitList);
12-
const item = array?.find(x => x.domain == url);
18+
const item = array?.find(x => isDomainEquals(x.domain, url));
1319
if (item != undefined) {
1420
const date = tab.days.find(x => x.date == todayLocalDate());
1521
if (date != undefined) {
16-
return date.summary >= item.time;
22+
if (date.summary >= item.time)
23+
return {
24+
IsLimitExceeded: true,
25+
LimitTime: item.time,
26+
};
1727
}
1828
}
1929

20-
return false;
30+
return {
31+
IsLimitExceeded: false,
32+
LimitTime: null,
33+
};
2134
}

0 commit comments

Comments
 (0)