Skip to content

Commit 650ed86

Browse files
committed
Add link to dashboard
1 parent 43dd5ea commit 650ed86

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

src/assets/icons/dashboard.svg

Lines changed: 2 additions & 0 deletions
Loading

src/pages/Dashboard.vue

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
type="radio"
1212
id="timeIntervalChart-tab"
1313
name="settings-group"
14-
checked
15-
v-on:change="selectTab(SettingsTab.TimeIntervalChart)"
14+
:checked="selectedTab == SettingsTab.Dashboard"
15+
v-on:change="selectTab(SettingsTab.Dashboard)"
1616
/>
1717
<label name="tabName" for="timeIntervalChart-tab">{{ t('dashboard.message') }}</label>
1818

1919
<div class="settings-content">
20-
<Dashboad v-if="selectedTab == SettingsTab.TimeIntervalChart" />
20+
<Dashboad v-if="selectedTab == SettingsTab.Dashboard" />
2121
</div>
2222
</div>
2323
<!-- <p class="tab-separator">Settings</p> -->
@@ -26,6 +26,7 @@
2626
type="radio"
2727
id="general-tab"
2828
name="settings-group"
29+
:checked="selectedTab == SettingsTab.GeneralSettings"
2930
v-on:change="selectTab(SettingsTab.GeneralSettings)"
3031
/>
3132
<label name="tabName" for="general-tab">{{ t('generalSettings.message') }}</label>
@@ -40,6 +41,7 @@
4041
type="radio"
4142
id="white-list-tab"
4243
name="settings-group"
44+
:checked="selectedTab == SettingsTab.WhiteList"
4345
v-on:change="selectTab(SettingsTab.WhiteList)"
4446
/>
4547
<label name="tabName" for="white-list-tab">{{ t('whiteListSettings.message') }}</label>
@@ -54,6 +56,7 @@
5456
type="radio"
5557
id="limits-tab"
5658
name="settings-group"
59+
:checked="selectedTab == SettingsTab.Limits"
5760
v-on:change="selectTab(SettingsTab.Limits)"
5861
/>
5962
<label name="tabName" for="limits-tab">{{ t('limitsSettings.message') }}</label>
@@ -67,6 +70,7 @@
6770
type="radio"
6871
id="notification-tab"
6972
name="settings-group"
73+
:checked="selectedTab == SettingsTab.Notifications"
7074
v-on:change="selectTab(SettingsTab.Notifications)"
7175
/>
7276
<label name="tabName" for="notification-tab">{{ t('notificationsSettings.message') }}</label>
@@ -81,6 +85,7 @@
8185
type="radio"
8286
id="about-tab"
8387
name="settings-group"
88+
:checked="selectedTab == SettingsTab.About"
8489
v-on:change="selectTab(SettingsTab.About)"
8590
/>
8691
<label name="tabName" for="about-tab">{{ t('aboutSettings.message') }}</label>
@@ -107,7 +112,20 @@ const { t } = useI18n();
107112
108113
const selectedTab = ref<SettingsTab>();
109114
110-
onMounted(() => (selectedTab.value = SettingsTab.TimeIntervalChart));
115+
onMounted(() => {
116+
const urlObj = new URL(location.href);
117+
const tabName = urlObj.searchParams.get('tab');
118+
if (tabName != null && tabName != '') {
119+
switch (tabName) {
120+
case 'dashboard':
121+
selectedTab.value = SettingsTab.Dashboard;
122+
break;
123+
case 'settings':
124+
selectedTab.value = SettingsTab.GeneralSettings;
125+
break;
126+
}
127+
} else selectedTab.value = selectedTab.value = SettingsTab.Dashboard;
128+
});
111129
112130
function selectTab(value: SettingsTab) {
113131
selectedTab.value = value;

src/pages/Popup.vue

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
</div>
77
<div class="icons-block">
88
<!-- <img height="17" src="../assets/icons/dark-mode.svg" /> -->
9-
<a @click="openDashboard()"
9+
<a @click="openPage(SettingsTab.Dashboard)"
10+
>{{ t('dashboard.message') }}<img height="22" src="../assets/icons/dashboard.svg"
11+
/></a>
12+
<a @click="openPage(SettingsTab.GeneralSettings)"
1013
>{{ t('settings.message') }}<img height="22" src="../assets/icons/settings.svg"
1114
/></a>
1215
</div>
@@ -74,13 +77,23 @@ import { useI18n } from 'vue-i18n';
7477
import Browser from 'webextension-polyfill';
7578
import TabList from '../components/TabList.vue';
7679
import ByDays from '../components/ByDays.vue';
77-
import { TypeOfList } from '../utils/enums';
80+
import { SettingsTab, TypeOfList } from '../utils/enums';
7881
7982
const { t } = useI18n();
8083
81-
async function openDashboard() {
84+
async function openPage(tab: SettingsTab) {
85+
let tabName = '';
86+
switch (tab) {
87+
case SettingsTab.Dashboard:
88+
tabName = 'dashboard';
89+
break;
90+
case SettingsTab.GeneralSettings:
91+
tabName = 'settings';
92+
break;
93+
}
94+
const url = Browser.runtime.getURL(`src/dashboard.html${tabName != '' ? `?tab=${tabName}` : ''}`);
8295
await Browser.tabs.create({
83-
url: Browser.runtime.getURL('src/dashboard.html'),
96+
url: url,
8497
active: true,
8598
});
8699
}

src/utils/enums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export enum SortingBy {
1111
}
1212

1313
export enum SettingsTab {
14-
TimeIntervalChart,
14+
Dashboard,
1515
GeneralSettings,
1616
WhiteList,
1717
Limits,

0 commit comments

Comments
 (0)