Skip to content

Commit 9de299d

Browse files
committed
adjust dashboard
1 parent 2929b22 commit 9de299d

File tree

19 files changed

+248
-59
lines changed

19 files changed

+248
-59
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
steps
22
PROCESS_EVENT
3+
**/node_modules/
34
docker
45
dev
56
docker-compose.admin.yml

dashboard/components/BarCard/Base.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts" setup>
22
33
4-
export type IconProvider = (id: string) => ['img' | 'icon', string] | undefined;
4+
export type IconProvider = (e: { _id: string, count: string } & any) => ['img' | 'icon', string] | undefined;
55
66
77
type Props = {
@@ -80,7 +80,7 @@ function openExternalLink(link: string) {
8080
</div>
8181
</div>
8282

83-
<div>
83+
<div class="h-full flex flex-col">
8484
<div class="flex justify-between font-bold text-text-sub/80 text-[1.1rem] mb-4">
8585
<div class="flex items-center gap-2">
8686
<div v-if="isDetailView" class="flex items-center justify-center">
@@ -111,13 +111,13 @@ function openExternalLink(link: string) {
111111
:style="'width:' + 100 / maxData * element.count + '%;'"></div>
112112

113113
<div class="flex px-2 py-1 relative items-center gap-4">
114-
<div v-if="iconProvider && iconProvider(element._id) != undefined"
114+
<div v-if="iconProvider && iconProvider(element) != undefined"
115115
class="flex items-center h-[1.3rem]">
116116

117-
<img v-if="iconProvider(element._id)?.[0] == 'img'" class="h-full"
118-
:style="customIconStyle" :src="iconProvider(element._id)?.[1]">
117+
<img v-if="iconProvider(element)?.[0] == 'img'" class="h-full"
118+
:style="customIconStyle" :src="iconProvider(element)?.[1]">
119119

120-
<i v-else :class="iconProvider(element._id)?.[1]"></i>
120+
<i v-else :class="iconProvider(element)?.[1]"></i>
121121
</div>
122122
<span class="text-ellipsis line-clamp-1 ui-font z-[20] text-[.95rem] text-text/70">
123123
{{ elementTextTransformer?.(element._id) || element._id }}
@@ -132,7 +132,7 @@ function openExternalLink(link: string) {
132132
No data yet
133133
</div>
134134
</div>
135-
<div v-if="!hideShowMore" class="flex justify-center mt-4 text-text-sub/90 ">
135+
<div v-if="!hideShowMore" class="flex justify-center mt-4 text-text-sub/90 items-end grow">
136136
<div @click="$emit('showMore')"
137137
class="poppins hover:bg-black cursor-pointer w-fit px-6 py-1 rounded-lg border-[1px] border-text-sub text-[.9rem]">
138138
Show more

dashboard/components/BarCard/Browsers.vue

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
<script lang="ts" setup>
22
3+
import type { IconProvider } from './Base.vue';
4+
5+
function iconProvider(e: { _id: string, flag: string, count: number }): ReturnType<IconProvider> {
6+
let name = e._id.toLowerCase().replace(/ /g, '-');
7+
8+
if (name === 'mobile-safari') name = 'safari';
9+
if (name === 'chrome-headless') name = 'chrome'
10+
if (name === 'chrome-webview') name = 'chrome'
11+
12+
if (name === 'duckduckgo') return ['icon', 'far fa-duck']
13+
if (name === 'avast-secure-browser') return ['icon', 'far fa-bug']
14+
if (name === 'avg-secure-browser') return ['icon', 'far fa-bug']
15+
16+
if (name === 'no_browser') return ['icon', 'far fa-question']
17+
if (name === 'gsa') return ['icon', 'far fa-question']
18+
if (name === 'miui-browser') return ['icon', 'far fa-question']
19+
20+
if (name === 'vivo-browser') return ['icon', 'far fa-question']
21+
if (name === 'whale') return ['icon', 'far fa-question']
22+
23+
if (name === 'twitter') return ['icon', 'fab fa-twitter']
24+
if (name === 'linkedin') return ['icon', 'fab fa-linkedin']
25+
if (name === 'facebook') return ['icon', 'fab fa-facebook']
26+
27+
return [
28+
'img',
29+
`https://github.com/alrra/browser-logos/blob/main/src/${name}/${name}_256x256.png?raw=true`
30+
]
31+
}
332
433
const browsersData = useFetch('/api/data/browsers', {
534
headers: useComputedHeaders({ limit: 10, }), lazy: true
@@ -8,15 +37,17 @@ const browsersData = useFetch('/api/data/browsers', {
837
const { showDialog, dialogBarData, isDataLoading } = useBarCardDialog();
938
1039
async function showMore() {
11-
dialogBarData.value=[];
40+
dialogBarData.value = [];
1241
showDialog.value = true;
1342
isDataLoading.value = true;
1443
1544
const res = await $fetch('/api/data/browsers', {
1645
headers: useComputedHeaders({ limit: 1000 }).value
1746
});
1847
19-
dialogBarData.value = res || [];
48+
dialogBarData.value = res?.map(e => {
49+
return { ...e, icon: iconProvider(e as any) }
50+
}) || [];
2051
2152
isDataLoading.value = false;
2253
@@ -28,8 +59,8 @@ async function showMore() {
2859
<template>
2960
<div class="flex flex-col gap-2">
3061
<BarCardBase @showMore="showMore()" @dataReload="browsersData.refresh()" :data="browsersData.data.value || []"
31-
desc="The browsers most used to search your website." :dataIcons="false"
32-
:loading="browsersData.pending.value" label="Top Browsers" sub-label="Browsers">
62+
desc="The browsers most used to search your website." :dataIcons="true" :iconProvider="iconProvider"
63+
:loading="browsersData.pending.value" label="Browsers" sub-label="Browsers">
3364
</BarCardBase>
3465
</div>
3566
</template>

dashboard/components/BarCard/Devices.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
<script lang="ts" setup>
22
33
4+
import type { IconProvider } from './Base.vue';
5+
6+
function iconProvider(e: { _id: string, count: number }): ReturnType<IconProvider> {
7+
if (e._id === 'desktop') return ['icon','far fa-desktop'];
8+
if (e._id === 'tablet') return ['icon','far fa-tablet'];
9+
if (e._id === 'mobile') return ['icon','far fa-mobile'];
10+
if (e._id === 'smarttv') return ['icon','far fa-tv'];
11+
if (e._id === 'console') return ['icon','far fa-game-console-handheld'];
12+
return ['icon', 'far fa-question']
13+
}
14+
15+
416
function transform(data: { _id: string, count: number }[]) {
517
console.log(data);
618
return data.map(e => ({ ...e, _id: e._id == null ? 'unknown' : e._id }))
@@ -34,9 +46,9 @@ async function showMore() {
3446

3547

3648
<template>
37-
<div class="flex flex-col gap-2">
49+
<div class="flex flex-col gap-2 h-full">
3850
<BarCardBase @showMore="showMore()" @dataReload="devicesData.refresh()" :data="devicesData.data.value || []"
39-
:dataIcons="false" desc="The devices most used to access your website." :loading="devicesData.pending.value"
40-
label="Top Devices" sub-label="Devices"></BarCardBase>
51+
:iconProvider="iconProvider" :dataIcons="true" desc="The devices most used to access your website."
52+
:loading="devicesData.pending.value" label="Devices" sub-label="Devices"></BarCardBase>
4153
</div>
4254
</template>

dashboard/components/BarCard/Geolocations.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,42 @@
22
33
import type { IconProvider } from '../BarCard/Base.vue';
44
5-
function iconProvider(id: string): ReturnType<IconProvider> {
6-
if (id === 'self') return ['icon', 'fas fa-link'];
5+
function iconProvider(e: { _id: string, flag: string, count: number }): ReturnType<IconProvider> {
6+
if (!e.flag) return ['icon', 'far fa-question']
77
return [
88
'img',
9-
`https://raw.githubusercontent.com/hampusborgos/country-flags/main/png250px/${id.toLowerCase()}.png`
9+
`https://raw.githubusercontent.com/hampusborgos/country-flags/main/png250px/${e.flag.toLowerCase()}.png`
1010
]
1111
}
1212
1313
const customIconStyle = `width: 2rem; padding: 1px;`
1414
1515
const geolocationData = useFetch('/api/data/countries', {
16-
headers: useComputedHeaders({ limit: 10, }), lazy: true
16+
headers: useComputedHeaders({ limit: 10, }), lazy: true,
17+
transform: (e) => {
18+
if (!e) return e;
19+
return e.map(k => {
20+
return { ...k, flag: k._id, _id: getCountryName(k._id) ?? k._id }
21+
})
22+
}
1723
});
1824
1925
2026
const { showDialog, dialogBarData, isDataLoading } = useBarCardDialog();
2127
2228
async function showMore() {
23-
dialogBarData.value=[];
29+
dialogBarData.value = [];
2430
showDialog.value = true;
2531
isDataLoading.value = true;
2632
2733
const res = await $fetch('/api/data/countries', {
28-
headers: useComputedHeaders({limit: 1000}).value
34+
headers: useComputedHeaders({ limit: 1000 }).value
2935
});
3036
31-
dialogBarData.value = res?.map(e => {
32-
return { ...e, icon: iconProvider(e._id) }
37+
dialogBarData.value = res?.map(k => {
38+
return { ...k, flag: k._id, _id: getCountryName(k._id) ?? k._id }
39+
}).map(e => {
40+
return { ...e, icon: iconProvider(e) }
3341
}) || [];
3442
3543
isDataLoading.value = false;
@@ -43,7 +51,7 @@ async function showMore() {
4351
<div class="flex flex-col gap-2">
4452
<BarCardBase @showMore="showMore()" @dataReload="geolocationData.refresh()"
4553
:data="geolocationData.data.value || []" :dataIcons="false" :loading="geolocationData.pending.value"
46-
label="Top Countries" sub-label="Countries" :iconProvider="iconProvider" :customIconStyle="customIconStyle"
54+
label="Countries" sub-label="Countries" :iconProvider="iconProvider" :customIconStyle="customIconStyle"
4755
desc=" Lists the countries where users access your website.">
4856
</BarCardBase>
4957
</div>

dashboard/components/BarCard/OperatingSystems.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ async function showMore() {
3131
<div class="flex flex-col gap-2 h-full">
3232
<BarCardBase @showMore="showMore()" @dataReload="ossData.refresh()" :data="ossData.data.value || []"
3333
desc="The operating systems most commonly used by your website's visitors." :dataIcons="false"
34-
:loading="ossData.pending.value" label="Top OS" sub-label="OSs"></BarCardBase>
34+
:loading="ossData.pending.value" label="OS" sub-label="OSs"></BarCardBase>
3535
</div>
3636
</template>

dashboard/components/BarCard/Referrers.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
import type { IconProvider } from './Base.vue';
44
5-
function iconProvider(id: string): ReturnType<IconProvider> {
6-
if (id === 'self') return ['icon', 'fas fa-link'];
7-
return ['img', `https://s2.googleusercontent.com/s2/favicons?domain=${id}&sz=64`]
5+
function iconProvider(e: { _id: string, count: number }): ReturnType<IconProvider> {
6+
if (e._id === 'self') return ['icon', 'fas fa-link'];
7+
return ['img', `https://s2.googleusercontent.com/s2/favicons?domain=${e._id}&sz=64`]
88
}
99
1010
function elementTextTransformer(element: string) {
@@ -22,18 +22,18 @@ const { showDialog, dialogBarData, isDataLoading } = useBarCardDialog();
2222
2323
async function showMore() {
2424
25-
dialogBarData.value=[];
26-
25+
dialogBarData.value = [];
26+
2727
showDialog.value = true;
2828
isDataLoading.value = true;
2929
3030
const res = await $fetch('/api/data/referrers', {
31-
headers: useComputedHeaders({limit: 1000}).value
31+
headers: useComputedHeaders({ limit: 1000 }).value
3232
});
3333
3434
3535
dialogBarData.value = res?.map(e => {
36-
return { ...e, icon: iconProvider(e._id) }
36+
return { ...e, icon: iconProvider(e as any) }
3737
}) || [];
3838
3939
isDataLoading.value = false;
@@ -47,7 +47,7 @@ async function showMore() {
4747
<BarCardBase @showMore="showMore()" :elementTextTransformer="elementTextTransformer"
4848
:iconProvider="iconProvider" @dataReload="referrersData.refresh()" :showLink=true
4949
:data="referrersData.data.value || []" :interactive="false" desc="Where users find your website."
50-
:dataIcons="true" :loading="referrersData.pending.value" label="Top Referrers" sub-label="Referrers">
50+
:dataIcons="true" :loading="referrersData.pending.value" label="Top Sources" sub-label="Referrers">
5151
</BarCardBase>
5252
</div>
5353
</template>

dashboard/components/FirstInteraction.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import 'highlight.js/styles/stackoverflow-dark.css';
77
import hljs from 'highlight.js';
88
import CardTitled from './CardTitled.vue';
99
10+
import { Lit } from 'litlyx-js';
11+
1012
const props = defineProps<{
1113
firstInteraction: boolean,
1214
refreshInteraction: () => any
@@ -19,6 +21,7 @@ onMounted(() => {
1921
function copyProjectId() {
2022
if (!navigator.clipboard) alert('You can\'t copy in HTTP');
2123
navigator.clipboard.writeText(project.value?._id?.toString() || '');
24+
Lit.event('no_visit_copy_id');
2225
createAlert('Success', 'Project id copied successfully.', 'far fa-circle-check', 5000);
2326
}
2427
@@ -36,6 +39,7 @@ function copyScript() {
3639
].join('')
3740
}
3841
42+
Lit.event('no_visit_copy_script');
3943
navigator.clipboard.writeText(createScriptText());
4044
createAlert('Success', 'Script copied successfully.', 'far fa-circle-check', 5000);
4145
}
@@ -53,6 +57,7 @@ const scriptText = computed(() => {
5357
function reloadPage() {
5458
location.reload();
5559
}
60+
5661
</script>
5762

5863
<template>
@@ -256,7 +261,9 @@ function reloadPage() {
256261
</defs>
257262
</svg>
258263
</div>
259-
<LyxUiButton type="secondary" to="https://docs.litlyx.com"> Visit documentation
264+
<LyxUiButton @click="Lit.event('no_visit_goto_docs')" type="secondary"
265+
to="https://docs.litlyx.com">
266+
Visit documentation
260267
</LyxUiButton>
261268
</div>
262269
</CardTitled>

dashboard/components/dashboard/TopCards.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const avgSessionDuration = computed(() => {
104104
<template>
105105
<div class="gap-6 px-6 grid grid-cols-1 md:grid-cols-2 xl:grid-cols-2 m-cards-wrap:grid-cols-4">
106106

107-
<DashboardCountCard :ready="!visitsData.pending.value" icon="far fa-earth" text="Total page visits"
107+
<DashboardCountCard :ready="!visitsData.pending.value" icon="far fa-earth" text="Total visits"
108108
:value="formatNumberK(visitsData.data.value?.data.reduce((a, e) => a + e, 0) || '...')"
109109
:avg="formatNumberK(avgVisitDay) + '/day'" :trend="visitsData.data.value?.trend"
110110
:data="visitsData.data.value?.data" :labels="visitsData.data.value?.labels" color="#5655d7">
@@ -116,15 +116,15 @@ const avgSessionDuration = computed(() => {
116116
</DashboardCountCard>
117117

118118

119-
<DashboardCountCard :ready="!sessionsData.pending.value" icon="far fa-user" text="Unique visits sessions"
119+
<DashboardCountCard :ready="!sessionsData.pending.value" icon="far fa-user" text="Unique visitors"
120120
:value="formatNumberK(sessionsData.data.value?.data.reduce((a, e) => a + e, 0) || '...')"
121121
:avg="formatNumberK(avgSessionsDay) + '/day'" :trend="sessionsData.data.value?.trend"
122122
:data="sessionsData.data.value?.data" :labels="sessionsData.data.value?.labels" color="#4abde8">
123123
</DashboardCountCard>
124124

125125

126126
<DashboardCountCard :ready="!sessionsDurationData.pending.value" icon="far fa-timer"
127-
text="Total avg session time" :value="avgSessionDuration" :trend="sessionsDurationData.data.value?.trend"
127+
text="Visit duration" :value="avgSessionDuration" :trend="sessionsDurationData.data.value?.trend"
128128
:data="sessionsDurationData.data.value?.data" :labels="sessionsDurationData.data.value?.labels"
129129
color="#f56523">
130130
</DashboardCountCard>

dashboard/components/dialog/DeleteDomainData.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ const props = defineProps<{
99
}>();
1010
1111
const isDone = ref<boolean>(false);
12+
const canDelete = ref<boolean>(false);
1213
1314
async function deleteData() {
1415
1516
try {
1617
if (props.deleteData.isAll) {
17-
18+
await $fetch('/api/settings/delete_all', {
19+
method: 'DELETE',
20+
headers: useComputedHeaders({ useSnapshotDates: false }).value,
21+
})
1822
} else {
1923
await $fetch('/api/settings/delete_domain', {
2024
method: 'DELETE',
@@ -60,9 +64,14 @@ async function deleteData() {
6064
</div>
6165

6266
<div class="grow"></div>
67+
68+
<div v-if="!isDone">
69+
<UCheckbox v-model="canDelete" label="Confirm data delete"></UCheckbox>
70+
</div>
71+
6372
<div v-if="!isDone" class="flex justify-end gap-2">
6473
<LyxUiButton type="secondary" @click="emit('cancel')"> Cancel </LyxUiButton>
65-
<LyxUiButton @click="deleteData()" :type="buttonType"> Confirm </LyxUiButton>
74+
<LyxUiButton :disabled="!canDelete" @click="canDelete ? deleteData() : () => { }" :type="buttonType"> Confirm </LyxUiButton>
6675
</div>
6776

6877
<div v-if="isDone" class="flex justify-end w-full">

0 commit comments

Comments
 (0)