feat(webui): display task count by type in activity bar tooltip

This commit is contained in:
Gauthier Roebroeck 2021-07-06 09:39:24 +08:00
parent eda767aeb5
commit 6b690bcdfb
4 changed files with 14 additions and 4 deletions

View file

@ -5,10 +5,12 @@ import {Module} from "vuex";
const vuexModule: Module<any, any> = { const vuexModule: Module<any, any> = {
state: { state: {
taskCount: 0, taskCount: 0,
taskCountByType: {} as { [key: string]: number },
}, },
mutations: { mutations: {
setTaskCount (state, val) { setTaskCount (state, event) {
state.taskCount = val state.taskCount = event.count
state.taskCountByType = event.countByType
}, },
}, },
} }

View file

@ -98,6 +98,6 @@ export default class KomgaSseService {
private updateTaskCount(event: any) { private updateTaskCount(event: any) {
const data = JSON.parse(event.data) as TaskQueueSseDto const data = JSON.parse(event.data) as TaskQueueSseDto
this.store.commit('setTaskCount', data.count) this.store.commit('setTaskCount', data)
} }
} }

View file

@ -44,6 +44,7 @@ export interface ThumbnailSeriesSseDto {
export interface TaskQueueSseDto { export interface TaskQueueSseDto {
count: number, count: number,
countByType: { [key: string]: number }
} }
export interface BookImportSseDto { export interface BookImportSseDto {

View file

@ -42,7 +42,11 @@
v-on="on" v-on="on"
/> />
</template> </template>
<span>{{ $tc('common.pending_tasks', taskCount) }}</span> <div class="mb-2">{{ $tc('common.pending_tasks', taskCount) }}</div>
<div v-for="taskType in Object.keys(taskCountByType)"
:key="taskType"
>{{ taskType }}: {{ taskCountByType[taskType] }}
</div>
</v-tooltip> </v-tooltip>
</v-list-item> </v-list-item>
@ -213,6 +217,9 @@ export default Vue.extend({
taskCount(): number { taskCount(): number {
return this.$store.state.komgaSse.taskCount return this.$store.state.komgaSse.taskCount
}, },
taskCountByType(): { [key: string]: number } {
return this.$store.state.komgaSse.taskCountByType
},
libraries(): LibraryDto[] { libraries(): LibraryDto[] {
return this.$store.state.komgaLibraries.libraries return this.$store.state.komgaLibraries.libraries
}, },