Skip to content

Commit

Permalink
fix application bug (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf-github-user authored Aug 19, 2024
1 parent d77cd82 commit 0c5ac0b
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix application bug",
"packageName": "@acedatacloud/nexior",
"email": "[email protected]",
"dependentChangeType": "patch"
}
1 change: 0 additions & 1 deletion src/components/luma/config/CustomSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default defineComponent({
...this.$store.state.luma?.config,
custom: val
});
console.log(JSON.stringify(this.$store.state.luma?.config));
}
}
},
Expand Down
10 changes: 6 additions & 4 deletions src/store/chat/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ export const getApplications = async ({
state,
rootState
}: ActionContext<IChatState, IRootState>): Promise<IApplication[]> => {
console.debug('start to get applications for chat');
return new Promise((resolve, reject) => {
console.debug('start to get applications for chat');
state.status.getApplications = Status.Request;
applicationOperator
.getAll({
user_id: rootState?.user?.id,
service_id: CHAT_SERVICE_ID
})
.then((response) => {
console.debug('get application success', response?.data);
console.debug('get applications success', response?.data);
state.status.getApplications = Status.Success;
commit('setApplications', response.data.items);
// check if there is any application with 'Period' type
const application = response.data.items?.find((application) => application?.type === IApplicationType.PERIOD);
const application2 = response.data.items?.find((application) => application?.type === IApplicationType.USAGE);
Expand All @@ -100,9 +99,12 @@ export const getApplications = async ({
);
console.debug('set credential with Usage', application);
commit('setCredential', credential);
} else {
console.debug('set application with null', response.data.items?.[0]);
commit('setApplication', response.data.items?.[0]);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
console.debug('save application success', response.data.items[0]);
})
.catch((error) => {
state.status.getApplications = Status.Error;
Expand Down
1 change: 0 additions & 1 deletion src/store/chat/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { IChatState } from './models';
export const resetAll = (state: IChatState): void => {
state.application = undefined;
state.conversations = undefined;
state.applications = undefined;
state.credential = undefined;
state.service = undefined;
};
Expand Down
7 changes: 4 additions & 3 deletions src/store/chatdoc/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const getApplications = async ({
.then((response) => {
console.debug('get applications success', response?.data);
state.status.getApplications = Status.Success;
commit('setApplications', response.data.items);
// check if there is any application with 'Period' type
const application = response.data.items?.find((application) => application?.type === IApplicationType.PERIOD);
const application2 = response.data.items?.find((application) => application?.type === IApplicationType.USAGE);
Expand All @@ -69,12 +68,14 @@ export const getApplications = async ({
);
console.debug('set credential with Usage', application);
commit('setCredential', credential);
} else {
console.debug('set application with null', response.data.items?.[0]);
commit('setApplication', response.data.items?.[0]);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
console.debug('save application success', response.data.items[0]);
})
.catch((error) => {
console.error('get applications error', error);
state.status.getApplications = Status.Error;
reject(error);
});
Expand Down
1 change: 1 addition & 0 deletions src/store/chatdoc/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IApplication, IChatdocRepository, ICredential, IService, Status } from
export interface IChatdocState {
service: IService | undefined;
application: IApplication | undefined;
applications: IApplication[] | undefined;
repositories: IChatdocRepository[] | undefined;
credential: ICredential | undefined;
status: {
Expand Down
4 changes: 4 additions & 0 deletions src/store/chatdoc/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const setService = (state: IChatdocState, payload: IService): void => {
export const setApplication = (state: IChatdocState, payload: IApplication): void => {
state.application = payload;
};
export const setApplications = (state: IChatdocState, payload: IApplication[]): void => {
state.applications = payload;
};

export const setRepositories = (state: IChatdocState, payload: IChatdocRepository[]): void => {
const currentRepositories = state.repositories;
Expand Down Expand Up @@ -63,6 +66,7 @@ export const setRepository = (state: IChatdocState, payload: IChatdocRepository)
export default {
setService,
setApplication,
setApplications,
setRepositories,
setRepository,
setCredential,
Expand Down
1 change: 1 addition & 0 deletions src/store/chatdoc/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default (): IChatdocState => {
return {
service: undefined,
application: undefined,
applications: undefined,
repositories: undefined,
credential: undefined,
status: {
Expand Down
9 changes: 5 additions & 4 deletions src/store/luma/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getApplications = async ({
state,
rootState
}: ActionContext<ILumaState, IRootState>): Promise<IApplication[]> => {
console.debug('start to get applications for qrart');
console.debug('start to get applications for luma');
return new Promise((resolve, reject) => {
state.status.getApplications = Status.Request;
applicationOperator
Expand All @@ -44,7 +44,6 @@ export const getApplications = async ({
.then((response) => {
console.debug('get applications success', response?.data);
state.status.getApplications = Status.Success;
commit('setApplication', response.data.items);
// check if there is any application with 'Period' type
const application = response.data.items?.find((application) => application?.type === IApplicationType.PERIOD);
const application2 = response.data.items?.find((application) => application?.type === IApplicationType.USAGE);
Expand All @@ -64,12 +63,14 @@ export const getApplications = async ({
);
console.debug('set credential with Usage', application);
commit('setCredential', credential);
} else {
console.debug('set application with null', response.data.items?.[0]);
commit('setApplication', response.data.items?.[0]);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
console.debug('save application success', response.data.items[0]);
})
.catch((error) => {
console.error('get applications error', error);
state.status.getApplications = Status.Error;
reject(error);
});
Expand Down
1 change: 1 addition & 0 deletions src/store/luma/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ILumaConfig, ILumaTask } from '@/models';

export interface ILumaState {
application: IApplication | undefined;
applications: IApplication[] | undefined;
service: IService | undefined;
credential: ICredential | undefined;
config: ILumaConfig | undefined;
Expand Down
5 changes: 5 additions & 0 deletions src/store/luma/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const setApplication = (state: ILumaState, payload: IApplication): void =
state.application = payload;
};

export const setApplications = (state: ILumaState, payload: IApplication[]): void => {
state.applications = payload;
};

export const setConfig = (state: ILumaState, payload: ILumaConfig): void => {
state.config = payload;
};
Expand Down Expand Up @@ -56,6 +60,7 @@ export const setTasks = (state: ILumaState, payload: any): void => {
export default {
setTasks,
setApplication,
setApplications,
setConfig,
setCredential,
setService,
Expand Down
1 change: 1 addition & 0 deletions src/store/luma/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default (): ILumaState => {
return {
service: undefined,
application: undefined,
applications: undefined,
tasks: undefined,
credential: undefined,
config: undefined,
Expand Down
4 changes: 3 additions & 1 deletion src/store/midjourney/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const getApplications = async ({
.then((response) => {
console.debug('get applications success', response?.data);
state.status.getApplications = Status.Success;
commit('setApplications', response.data.items);
// check if there is any application with 'Period' type
const application = response.data.items?.find((application) => application?.type === IApplicationType.PERIOD);
const application2 = response.data.items?.find((application) => application?.type === IApplicationType.USAGE);
Expand All @@ -76,6 +75,9 @@ export const getApplications = async ({
);
console.debug('set credential with Usage', application);
commit('setCredential', credential);
} else {
console.debug('set application with null', response.data.items?.[0]);
commit('setApplication', response.data.items?.[0]);
}
resolve(response.data.items);
console.debug('save application success', response.data.items[0]);
Expand Down
8 changes: 4 additions & 4 deletions src/store/midjourney/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export const resetAll = (state: IMidjourneyState): void => {
};
};

export const setApplications = (state: IMidjourneyState, payload: IApplication[]): void => {
state.applications = payload;
};

export const setService = (state: IMidjourneyState, payload: IService): void => {
state.service = payload;
};
Expand All @@ -27,6 +23,10 @@ export const setApplication = (state: IMidjourneyState, payload: IApplication):
state.application = payload;
};

export const setApplications = (state: IMidjourneyState, payload: IApplication[]): void => {
state.applications = payload;
};

export const setPreset = (state: IMidjourneyState, payload: IMidjourneyPreset): void => {
state.preset = payload;
};
Expand Down
7 changes: 4 additions & 3 deletions src/store/qrart/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const getApplications = async ({
.then((response) => {
console.debug('get applications success', response?.data);
state.status.getApplications = Status.Success;
commit('setApplications', response.data.items);
// check if there is any application with 'Period' type
const application = response.data.items?.find((application) => application?.type === IApplicationType.PERIOD);
const application2 = response.data.items?.find((application) => application?.type === IApplicationType.USAGE);
Expand All @@ -64,12 +63,14 @@ export const getApplications = async ({
);
console.debug('set credential with Usage', application);
commit('setCredential', credential);
} else {
console.debug('set application with null', response.data.items?.[0]);
commit('setApplication', response.data.items?.[0]);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
console.debug('save application success', response.data.items[0]);
})
.catch((error) => {
console.error('get applications error', error);
state.status.getApplications = Status.Error;
reject(error);
});
Expand Down
1 change: 0 additions & 1 deletion src/store/qrart/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { IQrartState } from './models';
export const resetAll = (state: IQrartState): void => {
state.service = undefined;
state.application = undefined;
state.applications = undefined;
state.config = undefined;
state.credential = undefined;
state.tasks = undefined;
Expand Down
7 changes: 5 additions & 2 deletions src/store/suno/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const getApplications = async ({
service_id: SUNO_SERVICE_ID
})
.then((response) => {
console.debug('get applications success', response?.data);
state.status.getApplications = Status.Success;
commit('setApplications', response.data.items);
// check if there is any application with 'Period' type
const application = response.data.items?.find((application) => application?.type === IApplicationType.PERIOD);
const application2 = response.data.items?.find((application) => application?.type === IApplicationType.USAGE);
Expand All @@ -63,9 +63,12 @@ export const getApplications = async ({
);
console.debug('set credential with Usage', application);
commit('setCredential', credential);
} else {
console.debug('set application with null', response.data.items?.[0]);
commit('setApplication', response.data.items?.[0]);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
console.debug('save application success', response.data.items[0]);
})
.catch((error) => {
state.status.getApplications = Status.Error;
Expand Down

0 comments on commit 0c5ac0b

Please sign in to comment.