Add drawai qrart pagination (#176)
This commit is contained in:
1 parent
c59c916b99
commit
094b7cd518
14 files changed
+202
-47
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"type": "patch",
|
||||||
|
"comment": "add drawai qrart pagination",
|
||||||
|
"packageName": "@acedatacloud/nexior",
|
||||||
|
"email": "1348977728@qq.com",
|
||||||
|
"dependentChangeType": "patch"
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="panel recent">
|
<div ref="panel" class="panel recent" @scroll="onHandleScroll">
|
||||||
<div v-if="tasks?.items === undefined" class="tasks">
|
<div v-if="tasks?.items === undefined" class="tasks">
|
||||||
<div v-for="_ in 3" :key="_" class="task placeholder">
|
<div v-for="_ in 3" :key="_" class="task placeholder">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
@@ -40,6 +40,7 @@ export default defineComponent({
|
|||||||
ElSkeleton,
|
ElSkeleton,
|
||||||
ElSkeletonItem
|
ElSkeletonItem
|
||||||
},
|
},
|
||||||
|
emits: ['reach-top'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
job: 0
|
job: 0
|
||||||
@@ -50,9 +51,18 @@ export default defineComponent({
|
|||||||
// reverse the order of the tasks.items
|
// reverse the order of the tasks.items
|
||||||
return {
|
return {
|
||||||
...this.$store.state.headshots?.tasks,
|
...this.$store.state.headshots?.tasks,
|
||||||
items: this.$store.state.headshots?.tasks?.items?.slice().reverse()
|
items: this.$store.state.headshots?.tasks?.items?.slice()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onHandleScroll() {
|
||||||
|
const el = this.$refs.panel as HTMLElement;
|
||||||
|
console.log('reach-top reach-top reach-top');
|
||||||
|
if (el.scrollTop === 0) {
|
||||||
|
this.$emit('reach-top');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -141,19 +141,19 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onExtend(event: MouseEvent, response: IPikaGenerateResponse) {
|
// onExtend(event: MouseEvent, response: IPikaGenerateResponse) {
|
||||||
event.stopPropagation();
|
// event.stopPropagation();
|
||||||
// extend url here
|
// // extend url here
|
||||||
console.debug('set config', response);
|
// console.debug('set config', response);
|
||||||
this.$store.commit('pika/setConfig', {
|
// this.$store.commit('pika/setConfig', {
|
||||||
...this.$store.state.pika?.config,
|
// ...this.$store.state.pika?.config,
|
||||||
video_id: response.video_id,
|
// video_id: response.video_id,
|
||||||
prompt: response.prompt,
|
// prompt: response.prompt,
|
||||||
action: 'extend',
|
// action: 'extend',
|
||||||
thumbnail_url: response.thumbnail_url,
|
// thumbnail_url: response.thumbnail_url,
|
||||||
video_url: response.video_url
|
// video_url: response.video_url
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
onDownload(event: MouseEvent, video_url: string) {
|
onDownload(event: MouseEvent, video_url: string) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
console.log('on download');
|
console.log('on download');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="panel recent">
|
<div ref="panel" class="panel recent" @scroll="onHandleScroll">
|
||||||
<div v-if="tasks?.items === undefined" class="tasks">
|
<div v-if="tasks?.items === undefined" class="tasks">
|
||||||
<div v-for="_ in 3" :key="_" class="task placeholder">
|
<div v-for="_ in 3" :key="_" class="task placeholder">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
@@ -40,6 +40,7 @@ export default defineComponent({
|
|||||||
ElSkeleton,
|
ElSkeleton,
|
||||||
ElSkeletonItem
|
ElSkeletonItem
|
||||||
},
|
},
|
||||||
|
emits: ['reach-top'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
job: 0
|
job: 0
|
||||||
@@ -50,9 +51,18 @@ export default defineComponent({
|
|||||||
// reverse the order of the tasks.items
|
// reverse the order of the tasks.items
|
||||||
return {
|
return {
|
||||||
...this.$store.state.qrart?.tasks,
|
...this.$store.state.qrart?.tasks,
|
||||||
items: this.$store.state.qrart?.tasks?.items?.slice().reverse()
|
items: this.$store.state.qrart?.tasks?.items?.slice()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onHandleScroll() {
|
||||||
|
const el = this.$refs.panel as HTMLElement;
|
||||||
|
console.log('reach-top reach-top reach-top');
|
||||||
|
if (el.scrollTop === 0) {
|
||||||
|
this.$emit('reach-top');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export interface IHeadshotsTask {
|
|||||||
_id: string;
|
_id: string;
|
||||||
api_id?: string;
|
api_id?: string;
|
||||||
application_id?: string;
|
application_id?: string;
|
||||||
created_at?: string;
|
created_at?: number;
|
||||||
credential_id?: string;
|
credential_id?: string;
|
||||||
trace_id?: string;
|
trace_id?: string;
|
||||||
user_id?: string;
|
user_id?: string;
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@ export interface IQrartGenerateResponse {
|
|||||||
|
|
||||||
export interface IQrartTask {
|
export interface IQrartTask {
|
||||||
id: string;
|
id: string;
|
||||||
created_at?: string;
|
created_at?: number;
|
||||||
request?: IQrartGenerateRequest;
|
request?: IQrartGenerateRequest;
|
||||||
response?: IQrartGenerateResponse;
|
response?: IQrartGenerateResponse;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,15 @@ class HeadshotsOperator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async tasks(
|
async tasks(
|
||||||
filter: { ids?: string[]; applicationId?: string; userId?: string; limit?: number; offset?: number },
|
filter: {
|
||||||
|
ids?: string[];
|
||||||
|
applicationId?: string;
|
||||||
|
userId?: string;
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
createdAtMax?: number;
|
||||||
|
createdAtMin?: number;
|
||||||
|
},
|
||||||
options: { token: string }
|
options: { token: string }
|
||||||
): Promise<AxiosResponse<IHeadshotsTasksResponse>> {
|
): Promise<AxiosResponse<IHeadshotsTasksResponse>> {
|
||||||
return await axios.post(
|
return await axios.post(
|
||||||
@@ -59,6 +67,16 @@ class HeadshotsOperator {
|
|||||||
? {
|
? {
|
||||||
offset: filter.offset
|
offset: filter.offset
|
||||||
}
|
}
|
||||||
|
: {}),
|
||||||
|
...(filter.createdAtMax !== undefined
|
||||||
|
? {
|
||||||
|
created_at_max: filter.createdAtMax
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...(filter.createdAtMin !== undefined
|
||||||
|
? {
|
||||||
|
created_at_min: filter.createdAtMin
|
||||||
|
}
|
||||||
: {})
|
: {})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+19
-1
@@ -23,7 +23,15 @@ class QrartOperator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async tasks(
|
async tasks(
|
||||||
filter: { ids?: string[]; applicationId?: string; userId?: string; limit?: number; offset?: number },
|
filter: {
|
||||||
|
ids?: string[];
|
||||||
|
applicationId?: string;
|
||||||
|
userId?: string;
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
createdAtMax?: number;
|
||||||
|
createdAtMin?: number;
|
||||||
|
},
|
||||||
options: { token: string }
|
options: { token: string }
|
||||||
): Promise<AxiosResponse<IQrartTasksResponse>> {
|
): Promise<AxiosResponse<IQrartTasksResponse>> {
|
||||||
return await axios.post(
|
return await axios.post(
|
||||||
@@ -54,6 +62,16 @@ class QrartOperator {
|
|||||||
? {
|
? {
|
||||||
offset: filter.offset
|
offset: filter.offset
|
||||||
}
|
}
|
||||||
|
: {}),
|
||||||
|
...(filter.createdAtMax !== undefined
|
||||||
|
? {
|
||||||
|
created_at_max: filter.createdAtMax
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...(filter.createdAtMin !== undefined
|
||||||
|
? {
|
||||||
|
created_at_min: filter.createdAtMin
|
||||||
|
}
|
||||||
: {})
|
: {})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
class="mb-4"
|
class="mb-4"
|
||||||
@refresh="onGetApplication"
|
@refresh="onGetApplication"
|
||||||
/>
|
/>
|
||||||
<recent-panel class="panel recent" />
|
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||||
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
|
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
|
||||||
</template>
|
</template>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -35,6 +35,7 @@ const CALLBACK_URL = 'https://webhook.acedata.cloud/headshots';
|
|||||||
interface IData {
|
interface IData {
|
||||||
task: IHeadshotsTask | undefined;
|
task: IHeadshotsTask | undefined;
|
||||||
job: number;
|
job: number;
|
||||||
|
timer: NodeJS.Timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -48,7 +49,9 @@ export default defineComponent({
|
|||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
task: undefined,
|
task: undefined,
|
||||||
job: 0
|
job: 0,
|
||||||
|
// @ts-ignore
|
||||||
|
timer: undefined
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -72,6 +75,21 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
application() {
|
application() {
|
||||||
return this.$store.state.headshots.application;
|
return this.$store.state.headshots.application;
|
||||||
|
},
|
||||||
|
tasks() {
|
||||||
|
return this.$store.state.headshots.tasks;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
tasks: {
|
||||||
|
handler(value, oldValue) {
|
||||||
|
// scroll down if new tasks are added
|
||||||
|
if (value?.items?.length > oldValue?.items?.length) {
|
||||||
|
console.debug('new tasks detected');
|
||||||
|
// this.onScrollDown();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
@@ -79,7 +97,7 @@ export default defineComponent({
|
|||||||
await this.onGetApplication();
|
await this.onGetApplication();
|
||||||
await this.onScrollDown();
|
await this.onScrollDown();
|
||||||
await this.onGetTasks();
|
await this.onGetTasks();
|
||||||
await this.onScrollDown();
|
// await this.onScrollDown();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.job = setInterval(() => {
|
this.job = setInterval(() => {
|
||||||
this.onGetTasks();
|
this.onGetTasks();
|
||||||
@@ -87,8 +105,15 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
async unmounted() {
|
async unmounted() {
|
||||||
clearInterval(this.job);
|
clearInterval(this.job);
|
||||||
|
clearInterval(this.timer);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async onReachTop() {
|
||||||
|
console.debug('reached top');
|
||||||
|
await this.onGetTasks({
|
||||||
|
createdAtMax: this.tasks?.items?.[0]?.created_at
|
||||||
|
});
|
||||||
|
},
|
||||||
async onGetService() {
|
async onGetService() {
|
||||||
console.debug('start onGetService');
|
console.debug('start onGetService');
|
||||||
await this.$store.dispatch('headshots/getService');
|
await this.$store.dispatch('headshots/getService');
|
||||||
@@ -125,14 +150,18 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
},
|
},
|
||||||
async onGetTasks() {
|
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
|
||||||
if (this.loading) {
|
if (this.loading) {
|
||||||
console.debug('loading');
|
console.debug('loading');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.debug('start onGetTasks', payload);
|
||||||
|
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
|
||||||
|
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
|
||||||
await this.$store.dispatch('headshots/getTasks', {
|
await this.$store.dispatch('headshots/getTasks', {
|
||||||
limit: 30,
|
limit,
|
||||||
offset: 0
|
createdAtMin,
|
||||||
|
createdAtMax
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async onGeneratePicture() {
|
async onGeneratePicture() {
|
||||||
@@ -165,8 +194,10 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(async () => {
|
.finally(async () => {
|
||||||
await this.onGetTasks();
|
setTimeout(async () => {
|
||||||
await this.onScrollDown();
|
await this.onGetTasks();
|
||||||
|
await this.onScrollDown();
|
||||||
|
}, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
class="mb-4"
|
class="mb-4"
|
||||||
@refresh="onGetApplication"
|
@refresh="onGetApplication"
|
||||||
/>
|
/>
|
||||||
<recent-panel class="panel recent" />
|
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||||
</template>
|
</template>
|
||||||
</layout>
|
</layout>
|
||||||
</template>
|
</template>
|
||||||
@@ -34,6 +34,7 @@ const CALLBACK_URL = 'https://webhook.acedata.cloud/qrart';
|
|||||||
interface IData {
|
interface IData {
|
||||||
task: IQrartTask | undefined;
|
task: IQrartTask | undefined;
|
||||||
job: number;
|
job: number;
|
||||||
|
timer: NodeJS.Timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -47,7 +48,9 @@ export default defineComponent({
|
|||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
task: undefined,
|
task: undefined,
|
||||||
job: 0
|
job: 0,
|
||||||
|
// @ts-ignore
|
||||||
|
timer: undefined
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -71,6 +74,21 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
application() {
|
application() {
|
||||||
return this.$store.state.qrart.application;
|
return this.$store.state.qrart.application;
|
||||||
|
},
|
||||||
|
tasks() {
|
||||||
|
return this.$store.state.qrart.tasks;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
tasks: {
|
||||||
|
handler(value, oldValue) {
|
||||||
|
// scroll down if new tasks are added
|
||||||
|
if (value?.items?.length > oldValue?.items?.length) {
|
||||||
|
console.debug('new tasks detected');
|
||||||
|
// this.onScrollDown();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
@@ -78,7 +96,7 @@ export default defineComponent({
|
|||||||
await this.onGetApplication();
|
await this.onGetApplication();
|
||||||
await this.onScrollDown();
|
await this.onScrollDown();
|
||||||
await this.onGetTasks();
|
await this.onGetTasks();
|
||||||
await this.onScrollDown();
|
// await this.onScrollDown();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.job = setInterval(() => {
|
this.job = setInterval(() => {
|
||||||
this.onGetTasks();
|
this.onGetTasks();
|
||||||
@@ -86,8 +104,15 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
async unmounted() {
|
async unmounted() {
|
||||||
clearInterval(this.job);
|
clearInterval(this.job);
|
||||||
|
clearInterval(this.timer);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async onReachTop() {
|
||||||
|
console.debug('reached top');
|
||||||
|
await this.onGetTasks({
|
||||||
|
createdAtMax: this.tasks?.items?.[0]?.created_at
|
||||||
|
});
|
||||||
|
},
|
||||||
async onGetService() {
|
async onGetService() {
|
||||||
console.debug('start onGetService');
|
console.debug('start onGetService');
|
||||||
await this.$store.dispatch('qrart/getService');
|
await this.$store.dispatch('qrart/getService');
|
||||||
@@ -124,14 +149,18 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
},
|
},
|
||||||
async onGetTasks() {
|
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
|
||||||
if (this.loading) {
|
if (this.loading) {
|
||||||
console.debug('loading');
|
console.debug('loading');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.debug('start onGetTasks', payload);
|
||||||
|
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
|
||||||
|
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
|
||||||
await this.$store.dispatch('qrart/getTasks', {
|
await this.$store.dispatch('qrart/getTasks', {
|
||||||
limit: 30,
|
limit,
|
||||||
offset: 0
|
createdAtMin,
|
||||||
|
createdAtMax
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async onGenerate() {
|
async onGenerate() {
|
||||||
@@ -181,8 +210,10 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(async () => {
|
.finally(async () => {
|
||||||
await this.onGetTasks();
|
setTimeout(async () => {
|
||||||
await this.onScrollDown();
|
await this.onGetTasks();
|
||||||
|
await this.onScrollDown();
|
||||||
|
}, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { IRootState } from '../common/models';
|
|||||||
import { IApplication, ICredential, IHeadshotsConfig, IHeadshotsTask, IService, IApplicationType } from '@/models';
|
import { IApplication, ICredential, IHeadshotsConfig, IHeadshotsTask, IService, IApplicationType } from '@/models';
|
||||||
import { Status } from '@/models/common';
|
import { Status } from '@/models/common';
|
||||||
import { HEADSHOTS_SERVICE_ID } from '@/constants';
|
import { HEADSHOTS_SERVICE_ID } from '@/constants';
|
||||||
|
import { mergeAndSortLists } from '@/utils/merge';
|
||||||
|
|
||||||
export const resetAll = ({ commit }: ActionContext<IHeadshotsState, IRootState>): void => {
|
export const resetAll = ({ commit }: ActionContext<IHeadshotsState, IRootState>): void => {
|
||||||
commit('resetAll');
|
commit('resetAll');
|
||||||
@@ -113,7 +114,12 @@ export const getService = async ({ commit, state }: ActionContext<IHeadshotsStat
|
|||||||
|
|
||||||
export const getTasks = async (
|
export const getTasks = async (
|
||||||
{ commit, state, rootState }: ActionContext<IHeadshotsState, IRootState>,
|
{ commit, state, rootState }: ActionContext<IHeadshotsState, IRootState>,
|
||||||
{ offset, limit }: { offset?: number; limit?: number }
|
{
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
createdAtMin,
|
||||||
|
createdAtMax
|
||||||
|
}: { offset?: number; limit?: number; createdAtMin?: number; createdAtMax?: number }
|
||||||
): Promise<IHeadshotsTask[]> => {
|
): Promise<IHeadshotsTask[]> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
console.debug('start to get tasks', offset, limit);
|
console.debug('start to get tasks', offset, limit);
|
||||||
@@ -125,15 +131,24 @@ export const getTasks = async (
|
|||||||
headshotsOperator
|
headshotsOperator
|
||||||
.tasks(
|
.tasks(
|
||||||
{
|
{
|
||||||
userId: rootState?.user?.id
|
userId: rootState?.user?.id,
|
||||||
|
createdAtMin,
|
||||||
|
createdAtMax
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
token
|
token
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.debug('get imagine tasks success', response.data.items);
|
console.debug('get videos tasks success', response.data.items);
|
||||||
commit('setTasksItems', response.data.items);
|
// merge with existing tasks
|
||||||
|
const existingItems = state?.tasks?.items || [];
|
||||||
|
console.debug('existing items', existingItems);
|
||||||
|
const newItems = response.data.items || [];
|
||||||
|
console.debug('new items', newItems);
|
||||||
|
// sort and de-duplicate using created_at
|
||||||
|
const mergedItems = mergeAndSortLists(existingItems, newItems);
|
||||||
|
commit('setTasksItems', mergedItems);
|
||||||
commit('setTasksTotal', response.data.count);
|
commit('setTasksTotal', response.data.count);
|
||||||
resolve(response.data.items);
|
resolve(response.data.items);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export default ['headshots.credential', 'headshots.application', 'headshots.tasks'];
|
export default ['headshots.credential', 'headshots.application'];
|
||||||
@@ -5,6 +5,7 @@ import { IRootState } from '../common/models';
|
|||||||
import { IApplication, IApplicationType, ICredential, IQrartConfig, IQrartTask, IService } from '@/models';
|
import { IApplication, IApplicationType, ICredential, IQrartConfig, IQrartTask, IService } from '@/models';
|
||||||
import { Status } from '@/models/common';
|
import { Status } from '@/models/common';
|
||||||
import { QRART_SERVICE_ID } from '@/constants';
|
import { QRART_SERVICE_ID } from '@/constants';
|
||||||
|
import { mergeAndSortLists } from '@/utils/merge';
|
||||||
|
|
||||||
export const resetAll = ({ commit }: ActionContext<IQrartState, IRootState>): void => {
|
export const resetAll = ({ commit }: ActionContext<IQrartState, IRootState>): void => {
|
||||||
commit('resetAll');
|
commit('resetAll');
|
||||||
@@ -113,7 +114,12 @@ export const getService = async ({ commit, state }: ActionContext<IQrartState, I
|
|||||||
|
|
||||||
export const getTasks = async (
|
export const getTasks = async (
|
||||||
{ commit, state, rootState }: ActionContext<IQrartState, IRootState>,
|
{ commit, state, rootState }: ActionContext<IQrartState, IRootState>,
|
||||||
{ offset, limit }: { offset?: number; limit?: number }
|
{
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
createdAtMin,
|
||||||
|
createdAtMax
|
||||||
|
}: { offset?: number; limit?: number; createdAtMin?: number; createdAtMax?: number }
|
||||||
): Promise<IQrartTask[]> => {
|
): Promise<IQrartTask[]> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
console.debug('start to get tasks', offset, limit);
|
console.debug('start to get tasks', offset, limit);
|
||||||
@@ -125,15 +131,24 @@ export const getTasks = async (
|
|||||||
qrartOperator
|
qrartOperator
|
||||||
.tasks(
|
.tasks(
|
||||||
{
|
{
|
||||||
userId: rootState?.user?.id
|
userId: rootState?.user?.id,
|
||||||
|
createdAtMin,
|
||||||
|
createdAtMax
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
token
|
token
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.debug('get imagine tasks success', response.data.items);
|
console.debug('get qrart tasks success', response.data.items);
|
||||||
commit('setTasksItems', response.data.items);
|
// merge with existing tasks
|
||||||
|
const existingItems = state?.tasks?.items || [];
|
||||||
|
console.debug('existing items', existingItems);
|
||||||
|
const newItems = response.data.items || [];
|
||||||
|
console.debug('new items', newItems);
|
||||||
|
// sort and de-duplicate using created_at
|
||||||
|
const mergedItems = mergeAndSortLists(existingItems, newItems);
|
||||||
|
commit('setTasksItems', mergedItems);
|
||||||
commit('setTasksTotal', response.data.count);
|
commit('setTasksTotal', response.data.count);
|
||||||
resolve(response.data.items);
|
resolve(response.data.items);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export default ['qrart.config', 'qrart.credential', 'qrart.application', 'qrart.tasks'];
|
export default ['qrart.config', 'qrart.credential', 'qrart.application'];
|
||||||
Reference in new issue
Block a user