Skip to content

Commit 4350e53

Browse files
authored
feat(manage): add CAS time dashboard on activity record (#636)
* deps(pnpm): update dependencies * fix(eslint): format code style * feat(manage): add CAS time dashboard on activity record * docs: add changeset
1 parent 3c50345 commit 4350e53

File tree

23 files changed

+8203
-10840
lines changed

23 files changed

+8203
-10840
lines changed

.changeset/slow-melons-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"enspire": minor
3+
---
4+
5+
Added a CAS time dashboard to the Activity Record, allowing for display of individual, combined, and total sums across all records.

.github/workflows/on-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/setup-node@v4
2424
with:
2525
node-version: 20
26-
cache: 'pnpm'
26+
cache: pnpm
2727
- name: Install dependencies
2828
run: pnpm install
2929
- name: Apply all pending migrations to the database

.github/workflows/on-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions/setup-node@v4
3232
with:
3333
node-version: 20
34-
cache: 'pnpm'
34+
cache: pnpm
3535
- name: Install dependencies
3636
run: pnpm install
3737
- name: Apply all pending migrations to the database

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ dist: jammy
66
cache:
77
npm: false
88
directories:
9-
- "~/.pnpm-store"
10-
9+
- ~/.pnpm-store
10+
1111
before_install:
1212
- corepack enable
1313
- corepack prepare pnpm@latest-9 --activate
1414
- pnpm config set store-dir ~/.pnpm-store
15-
15+
1616
install:
1717
- pnpm install
1818

components/custom/CAS/Record/ViewMyActivityRecords.vue

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<script setup lang="ts">
22
import type { Ref } from 'vue'
3-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
3+
import {
4+
Card,
5+
CardContent,
6+
CardDescription,
7+
CardHeader,
8+
CardTitle,
9+
} from '@/components/ui/card'
410
import {
511
Select,
612
SelectContent,
@@ -48,13 +54,33 @@ async function onRefresh() {
4854
isLoading.value = false
4955
}
5056
51-
watch(() => props.refreshWatcher, () => {
52-
onRefresh()
53-
})
57+
watch(
58+
() => props.refreshWatcher,
59+
() => {
60+
onRefresh()
61+
},
62+
)
5463
5564
watch(selectedClub, async () => {
5665
await onRefresh()
5766
})
67+
68+
// Computed properties to calculate total CAS times
69+
const totalCTime = computed(() => {
70+
return data.value?.data.reduce((sum, record) => sum + record.cTime, 0) || 0
71+
})
72+
73+
const totalATime = computed(() => {
74+
return data.value?.data.reduce((sum, record) => sum + record.aTime, 0) || 0
75+
})
76+
77+
const totalSTime = computed(() => {
78+
return data.value?.data.reduce((sum, record) => sum + record.sTime, 0) || 0
79+
})
80+
81+
const totalCASTime = computed(() => {
82+
return totalCTime.value + totalATime.value + totalSTime.value
83+
})
5884
</script>
5985

6086
<template>
@@ -76,18 +102,60 @@ watch(selectedClub, async () => {
76102
<SelectGroup>
77103
<SelectItem
78104
v-for="club in [...clubs.vice, ...clubs.president]"
79-
:key="club.id" :value="String(club.id)"
105+
:key="club.id"
106+
:value="String(club.id)"
80107
>
81108
{{ club.name.zh }}
82109
</SelectItem>
83110
</SelectGroup>
84111
</SelectContent>
85112
</Select>
86-
<Button size="icon" variant="outline" :disabled="isLoading || !selectedClub" @click="onRefresh()">
87-
<Icon name="material-symbols:refresh" :class="{ 'animate-spin': isLoading }" />
113+
<Button
114+
size="icon"
115+
variant="outline"
116+
:disabled="isLoading || !selectedClub"
117+
@click="onRefresh()"
118+
>
119+
<Icon
120+
name="material-symbols:refresh"
121+
:class="{ 'animate-spin': isLoading }"
122+
/>
88123
</Button>
89124
</div>
90-
<DataTable v-if="data && selectedClub" :columns="columns" :data="data.data" :refresh-function="refresh" />
125+
<div v-if="selectedClub" class="mb-4 text-sm">
126+
<div class="rounded border p-2 mt-1 flex justify-between">
127+
<div class="flex items-center space-x-0.5">
128+
<p class="font-bold">
129+
C:
130+
</p>
131+
<div>{{ totalCTime }} 小时</div>
132+
</div>
133+
<div class="flex items-center space-x-0.5">
134+
<p class="font-bold">
135+
A:
136+
</p>
137+
<div>{{ totalATime }} 小时</div>
138+
</div>
139+
<div class="flex items-center space-x-0.5">
140+
<p class="font-bold">
141+
S:
142+
</p>
143+
<div>{{ totalSTime }} 小时</div>
144+
</div>
145+
<div class="flex items-center space-x-0.5">
146+
<p class="font-bold">
147+
Total:
148+
</p>
149+
<div>{{ totalCASTime }} 小时</div>
150+
</div>
151+
</div>
152+
</div>
153+
<DataTable
154+
v-if="data && selectedClub"
155+
:columns="columns"
156+
:data="data.data"
157+
:refresh-function="refresh"
158+
/>
91159
</CardContent>
92160
</Card>
93161
<Toaster />

components/custom/CAS/Record/view-activity-records/DataTable.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
TableRow,
1313
} from '@/components/ui/table'
1414
import { valueUpdater } from '@/lib/utils'
15-
1615
import {
1716
FlexRender,
1817
getCoreRowModel,

components/custom/club-card.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script setup lang="ts">
22
import type { PropType } from 'vue'
3-
import type { Club } from '~/types/clubs'
3+
import Badge from '@/components/ui/badge/Badge.vue'
44
import { Button } from '@/components/ui/button'
55
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
66
import { cn } from '@/lib/utils'
7-
import Badge from '@/components/ui/badge/Badge.vue'
87
import sanitizeHtml from 'sanitize-html'
8+
import type { Club } from '~/types/clubs'
99
1010
const props = defineProps({
1111
club: {

components/custom/sidebar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if (import.meta.client) {
9292
</Button>
9393
</NuxtLink>
9494
<NuxtLink to="/manage/record">
95-
<Button v-if="isPresidentOrVicePresident" :variant="route.name === 'manage-record' ? 'secondary' : 'ghost'" class="w-full justify-start mt-1">
95+
<Button :variant="route.name === 'manage-record' ? 'secondary' : 'ghost'" class="w-full justify-start mt-1">
9696
<Icon class="mr-2 h-4 w-4" name="charm:tick-double" />
9797
活动签到
9898
</Button>

data/forms/forms.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
20240930_0001:
3-
title: "社团注册表"
4-
description: "提交社团注册表,如有多个社团可反复在此提交。"
5-
url: "https://wzvkx0jz.nocodb.com/#/nc/form/4b639cfb-a057-414f-b778-016c02309f32?embed"
6-
start_date: "2024-09-30"
7-
end_date: "2024-10-30"
3+
title: 社团注册表
4+
description: 提交社团注册表,如有多个社团可反复在此提交。
5+
url: 'https://wzvkx0jz.nocodb.com/#/nc/form/4b639cfb-a057-414f-b778-016c02309f32?embed'
6+
start_date: 2024-09-30
7+
end_date: 2024-10-30

db/migrations/migration_lock.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Please do not edit this file manually
22
# It should be added in your version-control system (i.e. Git)
3-
provider = "postgresql"
3+
provider = "postgresql"

0 commit comments

Comments
 (0)