Skip to content

Commit f989fd6

Browse files
committed
refactor: remove analytics tab and related functionality from Admin view
1 parent f29c534 commit f989fd6

2 files changed

Lines changed: 1 addition & 101 deletions

File tree

frontend/src/utils/analytics.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ export const EVENTS = {
6666
CREATE_USER: 'create-user',
6767
UPDATE_USER: 'update-user',
6868
DELETE_USER: 'delete-user',
69-
VIEW_ANALYTICS: 'view-analytics',
70-
OPEN_ANALYTICS_NEW_TAB: 'open-analytics-new-tab',
7169

7270
// Issue report events
7371
OPEN_ISSUE_REPORT: 'open-issue-report',

frontend/src/views/Admin.vue

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<TabList>
66
<Tab value="0">課程管理</Tab>
77
<Tab value="1">使用者管理</Tab>
8-
<Tab value="2">網站分析</Tab>
98
</TabList>
109
<TabPanels>
1110
<TabPanel value="0">
@@ -186,53 +185,6 @@
186185
</DataTable>
187186
</div>
188187
</TabPanel>
189-
190-
<TabPanel value="2">
191-
<div class="p-2 md:p-4 h-full">
192-
<div class="flex flex-column gap-3 h-full">
193-
<div class="flex justify-content-end align-items-center mb-2">
194-
<Button
195-
v-if="umamiShareUrl"
196-
label="在新視窗開啟"
197-
icon="pi pi-external-link"
198-
severity="secondary"
199-
size="small"
200-
@click="openUmamiInNewTab"
201-
/>
202-
</div>
203-
204-
<!-- Loading state -->
205-
<div
206-
v-if="umamiLoading"
207-
class="flex-1 flex align-items-center justify-content-center"
208-
>
209-
<ProgressSpinner strokeWidth="4" />
210-
</div>
211-
212-
<!-- Error state: No URL configured -->
213-
<div
214-
v-else-if="!umamiShareUrl"
215-
class="flex-1 flex flex-column align-items-center justify-content-center gap-4"
216-
>
217-
<i class="pi pi-exclamation-circle text-6xl text-red-500" />
218-
<div class="text-xl">無法載入網站分析</div>
219-
<div class="text-sm text-500">請聯絡管理員設定 Umami</div>
220-
</div>
221-
222-
<!-- Success state: Show iframe -->
223-
<div v-else class="umami-iframe-container">
224-
<iframe
225-
:src="umamiShareUrl"
226-
frameborder="0"
227-
class="umami-iframe"
228-
title="Umami Analytics"
229-
@load="handleUmamiLoaded"
230-
@error="handleUmamiError"
231-
></iframe>
232-
</div>
233-
</div>
234-
</div>
235-
</TabPanel>
236188
</TabPanels>
237189
</Tabs>
238190

@@ -432,15 +384,12 @@ const userFormErrors = ref({})
432384
433385
const currentUserId = computed(() => getCurrentUser()?.id)
434386
435-
const umamiShareUrl = ref(import.meta.env.VITE_UMAMI_SHARE_URL || '')
436-
const umamiLoading = ref(false)
437-
438387
const TAB_STORAGE_KEY = 'adminCurrentTab'
439388
440389
const getInitialTab = () => {
441390
try {
442391
const savedTab = localStorage.getItem(TAB_STORAGE_KEY)
443-
if (savedTab && ['0', '1', '2'].includes(savedTab)) {
392+
if (savedTab && ['0', '1'].includes(savedTab)) {
444393
return savedTab
445394
}
446395
} catch (e) {
@@ -451,27 +400,6 @@ const getInitialTab = () => {
451400
452401
const currentTab = ref(getInitialTab())
453402
454-
const openUmamiInNewTab = () => {
455-
if (umamiShareUrl.value) {
456-
trackEvent(EVENTS.OPEN_ANALYTICS_NEW_TAB)
457-
window.open(umamiShareUrl.value, '_blank')
458-
}
459-
}
460-
461-
const handleUmamiLoaded = () => {
462-
umamiLoading.value = false
463-
}
464-
465-
const handleUmamiError = () => {
466-
umamiLoading.value = false
467-
toast.add({
468-
severity: 'error',
469-
summary: '錯誤',
470-
detail: '無法載入 Umami 分析頁面',
471-
life: 3000,
472-
})
473-
}
474-
475403
const categoryOptions = [
476404
{ name: '大一課程', value: 'freshman' },
477405
{ name: '大二課程', value: 'sophomore' },
@@ -914,16 +842,11 @@ const handleTabChange = (value) => {
914842
const tabNames = {
915843
0: 'courses',
916844
1: 'users',
917-
2: 'analytics',
918845
}
919846
920847
trackEvent(EVENTS.SWITCH_TAB, {
921848
tab: tabNames[value] || value,
922849
})
923-
924-
if (value === '2') {
925-
trackEvent(EVENTS.VIEW_ANALYTICS)
926-
}
927850
}
928851
929852
onMounted(() => {
@@ -1022,29 +945,8 @@ onMounted(() => {
1022945
flex-wrap: wrap;
1023946
}
1024947
1025-
.umami-iframe-container {
1026-
width: 100%;
1027-
height: calc(100vh - var(--navbar-height) - 200px);
1028-
min-height: 600px;
1029-
border: 1px solid var(--border-color);
1030-
border-radius: 8px;
1031-
overflow: hidden;
1032-
background: var(--bg-primary);
1033-
}
1034-
1035-
.umami-iframe {
1036-
width: 100%;
1037-
height: 100%;
1038-
border: none;
1039-
}
1040-
1041948
/* Mobile responsive adjustments */
1042949
@media (max-width: 768px) {
1043-
.umami-iframe-container {
1044-
height: calc(100vh - var(--navbar-height) - 200px);
1045-
min-height: 400px;
1046-
}
1047-
1048950
:deep(.p-dialog .p-dialog-content) {
1049951
font-size: 0.875rem;
1050952
}

0 commit comments

Comments
 (0)