Line data Source code
1 : import type { JobGroup, JobListItem } from '@/composables/queue/useJobList'
2 :
3 : export type VirtualJobRow =
4 : | {
5 : key: string
6 : type: 'header'
7 : label: string
8 : }
9 : | {
10 : key: string
11 : type: 'job'
12 : job: JobListItem
13 : }
14 :
15 41 : export function buildVirtualJobRows(
16 : displayedJobGroups: JobGroup[]
17 : ): VirtualJobRow[] {
18 41 : const rows: VirtualJobRow[] = []
19 :
20 41 : displayedJobGroups.forEach((group) => {
21 24 : rows.push({
22 : key: `header-${group.key}`,
23 : type: 'header',
24 : label: group.label
25 : })
26 :
27 24 : group.items.forEach((job) => {
28 88 : rows.push({
29 : key: `job-${job.id}`,
30 : type: 'job',
31 : job
32 : })
33 : })
34 : })
35 :
36 41 : return rows
37 : }
|