diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json index 01a83e4..68a4f58 100644 --- a/src/_locales/de/messages.json +++ b/src/_locales/de/messages.json @@ -235,5 +235,18 @@ "enjoyAndReview": { "message": "Genießen Sie die Erweiterung?", "description": "Bewerten Web Activity Time Tracker" + }, + "removeAllData": { + "message": "Alle Daten entfernen", + "description": "Sie können alle Daten und Statistiken der besuchten Websites für immer löschen." + }, + "remove": { + "message": "Entfernen" + }, + "removeAllDataConfirm": { + "message": "Sind Sie sicher, dass Sie alle Daten löschen möchten?" + }, + "cancel": { + "message": "Annullierung" } } diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 2633710..5d5364c 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -235,5 +235,18 @@ "enjoyAndReview": { "message": "Enjoying the extension?", "description": "Rate Web Activity Time Tracker" + }, + "removeAllData": { + "message": "Remove all data", + "description": "You can delete all data and statistics of visited websites for all time" + }, + "remove": { + "message": "Remove" + }, + "removeAllDataConfirm": { + "message": "Are you sure you want to delete all data?" + }, + "cancel": { + "message": "Cancel" } } diff --git a/src/_locales/ru/messages.json b/src/_locales/ru/messages.json index 0794fab..015dd21 100644 --- a/src/_locales/ru/messages.json +++ b/src/_locales/ru/messages.json @@ -235,5 +235,18 @@ "enjoyAndReview": { "message": "Вам нравится расширение?", "description": "Оцените Web Activity Time Tracker" + }, + "removeAllData": { + "message": "Удалить все данные", + "description": "Вы можете удалить все данные и статистику посещенных сайтов за все время" + }, + "remove": { + "message": "Удалить" + }, + "removeAllDataConfirm": { + "message": "Вы уверены, что хотите удалить все данные, включая статистику посещенных сайтов?" + }, + "cancel": { + "message": "Отмена" } } diff --git a/src/assets/css/general.css b/src/assets/css/general.css index 94d2e40..b179477 100644 --- a/src/assets/css/general.css +++ b/src/assets/css/general.css @@ -79,8 +79,58 @@ input[type='button']:hover { text-decoration: none; } +input[type='button'].alert { + background: #fe5c5c !important; +} + +input[type='button'].info { + background: #ffffff !important; + color: black; + border: 1px solid black; +} + input[type='button'][disabled] { border: 1px solid #999999; background-color: #cccccc; color: #666666; } +.modal { + display: block; + position: fixed; + z-index: 1; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgb(0,0,0); + background-color: rgba(0,0,0,0.4); +} + +.modal-content { + background-color: #fefefe; + margin: 15% auto; + padding: 20px; + border: 1px solid #888; + width: 40%; + border-radius: 10px; +} + +.modal-content p{ + font-size: 18px; + font-weight: 600; +} + +.close { + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; +} + +.close:hover, +.close:focus { + color: black; + text-decoration: none; + cursor: pointer; +} diff --git a/src/assets/icons/dashboard.svg b/src/assets/icons/dashboard.svg index 8789249..099ec8c 100644 --- a/src/assets/icons/dashboard.svg +++ b/src/assets/icons/dashboard.svg @@ -1,2 +1,6 @@ - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/src/assets/icons/settings.svg b/src/assets/icons/settings.svg index 206e8a9..4096f43 100644 --- a/src/assets/icons/settings.svg +++ b/src/assets/icons/settings.svg @@ -1,2 +1,5 @@ - \ No newline at end of file + + + + \ No newline at end of file diff --git a/src/components/GeneralSettings.vue b/src/components/GeneralSettings.vue index 12ee14a..52c5d8e 100644 --- a/src/components/GeneralSettings.vue +++ b/src/components/GeneralSettings.vue @@ -81,6 +81,25 @@ +
+ +

{{ t('removeAllData.description') }}

+ +
+ diff --git a/src/repository/tabs-repository-interface.ts b/src/repository/tabs-repository-interface.ts index a14b124..9c5ff02 100644 --- a/src/repository/tabs-repository-interface.ts +++ b/src/repository/tabs-repository-interface.ts @@ -2,6 +2,7 @@ import { Tab } from '../entity/tab'; export interface ITabsRepository { getTabs(): Tab[]; + removeAllTabs(): void; getTodayTabs(): Tab[]; getTab(domain: string): Tab | undefined; addTab(domain: string, favicon: string | undefined): Promise; diff --git a/src/repository/tabs-repository.ts b/src/repository/tabs-repository.ts index 73b59f3..b3c555e 100644 --- a/src/repository/tabs-repository.ts +++ b/src/repository/tabs-repository.ts @@ -20,6 +20,10 @@ export class TabsRepository implements ITabsRepository { return this.tabs; } + removeAllTabs(): void { + this.tabs = []; + } + getTodayTabs(): Tab[] { return this.tabs.filter(x => x.days.find(s => s.date === todayLocalDate())); } diff --git a/src/tracker.ts b/src/tracker.ts index 054ea9e..b22e7aa 100644 --- a/src/tracker.ts +++ b/src/tracker.ts @@ -16,6 +16,7 @@ import { convertSummaryTimeToBadgeString } from './utils/converter'; import { Settings } from './compositions/settings'; import { isNeedToShowNotification } from './compositions/notification-list'; import { NotificationType, showNotification } from './compositions/show-notification'; +import { Messages } from './utils/messages'; const activeTabInstance = ActiveTab.getInstance(); @@ -160,3 +161,12 @@ async function saveTabs() { const tabs = repo.getTabs(); await storage.saveTabs(tabs); } + +Browser.runtime.onMessage.addListener(async message => { + if (message == Messages.ClearAllData) { + const storage = injecStorage(); + const repo = await injectTabsRepositorySingleton(); + repo.removeAllTabs(); + await storage.saveTabs([]); + } +}); diff --git a/src/utils/messages.ts b/src/utils/messages.ts index 362dba9..201522f 100644 --- a/src/utils/messages.ts +++ b/src/utils/messages.ts @@ -1,3 +1,4 @@ export enum Messages { RescheduleJobs = 'reschedule-jobs', + ClearAllData = 'clear-data', }