mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-09-10 22:14:48 -05:00
feat(@xen-orchestra/rest-api): add reactivity on task store (#9271)
This commit is contained in:
@@ -632,6 +632,7 @@ export type XoTask = {
|
||||
end?: number
|
||||
id: Branded<'task'>
|
||||
infos?: { data: unknown; message: string }[]
|
||||
progress?: number
|
||||
properties: {
|
||||
method?: string
|
||||
name?: string
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import { useXoCollectionState } from '@/composables/xo-collection-state/use-xo-collection-state.ts'
|
||||
import { convertTaskToCore } from '@/utils/convert-task-to-core.util.ts'
|
||||
import { watchCollectionWrapper } from '@/utils/sse.util'
|
||||
import { defineRemoteResource } from '@core/packages/remote-resource/define-remote-resource.ts'
|
||||
import type { XoTask } from '@vates/types'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const ONE_DAY = 24 * 60 * 60 * 1000
|
||||
|
||||
const taskFields: (keyof XoTask)[] = ['id', 'start', 'end', 'properties', 'status', 'progress', 'tasks'] as const
|
||||
|
||||
export const useXoTaskCollection = defineRemoteResource({
|
||||
url: '/rest/v0/tasks?fields=id,start,end,properties,status,progress,tasks',
|
||||
url: `/rest/v0/tasks?fields=${taskFields}`,
|
||||
watchCollection: watchCollectionWrapper({ resource: 'task', fields: taskFields }),
|
||||
initialData: () => [] as XoTask[],
|
||||
state: (tasks, context) => {
|
||||
const lastDayTasks = computed(() => {
|
||||
|
||||
@@ -28,7 +28,7 @@ export function watchCollectionWrapper<T>({
|
||||
handleWatching?: THandleWatching
|
||||
predicate?: (receivedObj: T | T[], context: ResourceContext<any[]> | undefined) => boolean
|
||||
}) {
|
||||
const _getType: (obj: unknown) => string | undefined = getType ?? ((obj: any) => obj.type)
|
||||
const _getType: (obj: unknown) => string | undefined = getType ?? ((obj: any) => obj.$subscription)
|
||||
const _getIdentifier: (obj: unknown) => string | undefined = getIdentifier ?? ((obj: any) => obj.id)
|
||||
|
||||
if (handleDelete === undefined) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
- **XO 6:**
|
||||
- [i18n] Update Czech, Danish, Spanish, French, Italian, Dutch, Portuguese (Brazil), and Russian translations (PR [#9243](https://github.com/vatesfr/xen-orchestra/pull/9243))
|
||||
- [Reactivity] Tasks are now reactive (PR [#9271](https://github.com/vatesfr/xen-orchestra/pull/9271))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
@@ -39,8 +40,10 @@
|
||||
|
||||
<!--packages-start-->
|
||||
|
||||
- @vates/types minor
|
||||
- @xen-orchestra/mixins minor
|
||||
- @xen-orchestra/rest-api minor
|
||||
- @xen-orchestra/web minor
|
||||
- @xen-orchestra/web-core minor
|
||||
|
||||
<!--packages-end-->
|
||||
|
||||
Reference in New Issue
Block a user