Add application selection (#186)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
7af0e714cd
commit
d357d1c857
24 files changed
+266
-48
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "minor",
|
||||
"comment": "add applictions selection",
|
||||
"packageName": "@acedatacloud/nexior",
|
||||
"email": "office@acedata.cloud",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<span v-if="application.type === 'Period'" class="info">
|
||||
<el-tag v-if="showType" type="primary" class="mr-1" effect="dark">
|
||||
{{ $t('application.type.period') }}
|
||||
</el-tag>
|
||||
{{ $t('common.message.expiredAt') }}:
|
||||
{{ $dayjs.format(application.expired_at) }}
|
||||
<p v-if="showId" class="subtitle">ID: {{ application.id }}</p>
|
||||
</span>
|
||||
<span v-if="application.type === 'Usage'" type="success" class="info" effect="dark">
|
||||
<el-tag v-if="showType" class="mr-1">
|
||||
{{ $t('application.type.usage') }}
|
||||
</el-tag>
|
||||
{{ $t('common.message.remainingAmount') }}:
|
||||
{{ application?.remaining_amount?.toFixed(6) }}
|
||||
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
|
||||
<p v-if="showId" class="subtitle">ID: {{ application.id }}</p>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IApplication } from '@/models';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElTag } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApplicationInfo',
|
||||
components: {
|
||||
ElTag
|
||||
},
|
||||
props: {
|
||||
application: {
|
||||
type: Object as () => IApplication,
|
||||
required: true
|
||||
},
|
||||
showType: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showId: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.info {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-primary);
|
||||
text-align: center;
|
||||
line-height: 28px;
|
||||
}
|
||||
.subtitle {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -8,15 +8,21 @@
|
||||
</el-skeleton>
|
||||
</div>
|
||||
<div v-else-if="application" class="status">
|
||||
<span v-if="application.type === 'Period'" class="info">
|
||||
{{ $t('common.message.expiredAt') }}:
|
||||
{{ $dayjs.format(application.expired_at) }}
|
||||
</span>
|
||||
<span v-if="application.type === 'Usage'" class="info">
|
||||
{{ $t('common.message.remainingAmount') }}:
|
||||
{{ application?.remaining_amount?.toFixed(6) }}
|
||||
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
|
||||
</span>
|
||||
<el-dropdown @command="onSelectApplication">
|
||||
<span class="el-dropdown-link">
|
||||
<application-info :application="application" />
|
||||
<el-icon v-if="applications && applications.length > 0" class="el-icon--right">
|
||||
<arrow-down />
|
||||
</el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu v-if="applications && applications.length > 0">
|
||||
<el-dropdown-item v-for="(app, index) in applications" :key="index" :command="app">
|
||||
<application-info :application="app" :show-type="true" :show-id="true" />
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<span class="actions">
|
||||
<el-button round size="small" type="primary" class="mr-1" @click="onBuyMore(application)">{{
|
||||
$t('common.button.buyMore')
|
||||
@@ -49,12 +55,23 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { applicationOperator, credentialOperator } from '@/operators';
|
||||
import { ElButton, ElMessage, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import {
|
||||
ElButton,
|
||||
ElMessage,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem,
|
||||
ElDropdown,
|
||||
ElDropdownItem,
|
||||
ElIcon,
|
||||
ElDropdownMenu
|
||||
} from 'element-plus';
|
||||
import ApplicationConfirm from '@/components/application/Confirm.vue';
|
||||
import { IApplicationType, IApplication, IApplicationDetailResponse, IService } from '@/models';
|
||||
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
|
||||
import { ROUTE_CONSOLE_APPLICATION_SUBSCRIBE } from '@/router';
|
||||
import ApiPrice from '@/components/api/Price.vue';
|
||||
import { ArrowDown } from '@element-plus/icons-vue';
|
||||
import ApplicationInfo from './Info.vue';
|
||||
|
||||
export interface IData {
|
||||
confirming: boolean;
|
||||
@@ -63,12 +80,28 @@ export interface IData {
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApplicationStatus',
|
||||
components: { ElButton, ApplicationConfirm, ElSkeleton, ElSkeletonItem, ApiPrice },
|
||||
components: {
|
||||
ElButton,
|
||||
ApplicationInfo,
|
||||
ApplicationConfirm,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem,
|
||||
ApiPrice,
|
||||
ElDropdown,
|
||||
ElDropdownMenu,
|
||||
ElDropdownItem,
|
||||
ArrowDown,
|
||||
ElIcon
|
||||
},
|
||||
props: {
|
||||
application: {
|
||||
type: Object as () => IApplication | undefined,
|
||||
required: true
|
||||
},
|
||||
applications: {
|
||||
type: Array as () => IApplication[] | undefined,
|
||||
default: undefined
|
||||
},
|
||||
initializing: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -86,7 +119,7 @@ export default defineComponent({
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: ['apply', 'refresh', 'applied', 'update:application'],
|
||||
emits: ['apply', 'refresh', 'applied', 'update:application', 'select'],
|
||||
data(): IData {
|
||||
return {
|
||||
confirming: this.needApply,
|
||||
@@ -143,6 +176,9 @@ export default defineComponent({
|
||||
this.$emit('applied');
|
||||
});
|
||||
},
|
||||
onSelectApplication(application: IApplication) {
|
||||
this.$emit('select', application);
|
||||
},
|
||||
onApply() {
|
||||
applicationOperator
|
||||
.create({
|
||||
@@ -175,12 +211,15 @@ export default defineComponent({
|
||||
display: block;
|
||||
width: fit-content;
|
||||
margin: auto;
|
||||
.el-icon {
|
||||
position: relative;
|
||||
top: 0.2em;
|
||||
}
|
||||
.el-dropdown {
|
||||
line-height: 20px;
|
||||
}
|
||||
}
|
||||
.info {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.actions {
|
||||
margin: 0 5px;
|
||||
display: inline-block;
|
||||
|
||||
@@ -39,14 +39,13 @@ export default defineComponent({
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item {
|
||||
height: 80px;
|
||||
// height: 80px;
|
||||
font-size: 14px;
|
||||
background-color: var(--el-color-color);
|
||||
color: var(--el-text-color-primary);
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:need-apply="needApply"
|
||||
:service="service"
|
||||
@select="$store.dispatch('chat/setApplication', $event)"
|
||||
@refresh="$store.dispatch('chat/getApplications')"
|
||||
/>
|
||||
<div :class="{ dialogue: true, empty: messages.length === 0 }">
|
||||
@@ -152,6 +154,9 @@ export default defineComponent({
|
||||
application() {
|
||||
return this.$store.state.chat.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.chat.applications;
|
||||
},
|
||||
credential() {
|
||||
return this.$store.state.chat?.credential;
|
||||
},
|
||||
@@ -173,13 +178,6 @@ export default defineComponent({
|
||||
await this.$store.dispatch('chat/setModel', model);
|
||||
}
|
||||
},
|
||||
// async references(val) {
|
||||
// console.log('references changed', val);
|
||||
// const model = await this.getModelByAction();
|
||||
// if (model) {
|
||||
// await this.$store.dispatch('chat/setModel', model);
|
||||
// }
|
||||
// },
|
||||
async isReasonActive(val) {
|
||||
console.log('reason changed', val);
|
||||
const model = await this.getModelByAction();
|
||||
@@ -385,7 +383,10 @@ export default defineComponent({
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].state = IChatMessageState.FAILED;
|
||||
}
|
||||
console.error(error);
|
||||
if (error.name === 'AbortError') {
|
||||
console.error('aborted');
|
||||
return;
|
||||
}
|
||||
if (axios.isCancel(error)) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_CANCELED
|
||||
@@ -460,6 +461,10 @@ export default defineComponent({
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].state = IChatMessageState.FAILED;
|
||||
}
|
||||
if (error.name === 'AbortError') {
|
||||
console.error('aborted');
|
||||
return;
|
||||
}
|
||||
if (axios.isCancel(error)) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_CANCELED
|
||||
@@ -469,7 +474,6 @@ export default defineComponent({
|
||||
if (isJSONString(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
console.debug('error', data);
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = data.error;
|
||||
}
|
||||
@@ -616,6 +620,10 @@ export default defineComponent({
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].state = IChatMessageState.FAILED;
|
||||
}
|
||||
if (error.name === 'AbortError') {
|
||||
console.error('aborted');
|
||||
return;
|
||||
}
|
||||
console.error(error);
|
||||
if (axios.isCancel(error)) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('application.field.type')" width="80px">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row?.type === 'Period'" type="success">
|
||||
<el-tag v-if="scope.row?.type === 'Period'" type="success" effect="dark">
|
||||
{{ $t('application.type.period') }}
|
||||
</el-tag>
|
||||
<el-tag v-if="scope.row?.type === 'Usage'" type="primary">
|
||||
<el-tag v-if="scope.row?.type === 'Usage'" effect="dark">
|
||||
{{ $t('application.type.usage') }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
@refresh="onGetApplication"
|
||||
@select="$store.dispatch('flux/setApplication', $event)"
|
||||
/>
|
||||
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
|
||||
@@ -76,6 +78,9 @@ export default defineComponent({
|
||||
application() {
|
||||
return this.$store.state.flux?.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.flux?.applications;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.flux?.tasks;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
@refresh="onGetApplication"
|
||||
@select="$store.dispatch('hailuo/setApplication', $event)"
|
||||
/>
|
||||
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
|
||||
@@ -76,6 +78,9 @@ export default defineComponent({
|
||||
application() {
|
||||
return this.$store.state.hailuo.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.hailuo.applications;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.hailuo.tasks;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
@refresh="onGetApplication"
|
||||
@select="$store.dispatch('headshots/setApplication', $event)"
|
||||
/>
|
||||
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
|
||||
@@ -76,6 +78,9 @@ export default defineComponent({
|
||||
application() {
|
||||
return this.$store.state.headshots.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.headshots.applications;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.headshots.tasks;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
@refresh="onGetApplication"
|
||||
@select="$store.dispatch('luma/setApplication', $event)"
|
||||
/>
|
||||
<recent-panel class="panel recent" />
|
||||
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
|
||||
@@ -72,6 +74,9 @@ export default defineComponent({
|
||||
},
|
||||
application() {
|
||||
return this.$store.state.luma.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.luma.applications;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
@refresh="onGetApplication"
|
||||
@select="$store.dispatch('midjourney/setApplication', $event)"
|
||||
/>
|
||||
<task-list @custom="onCustom" @reach-top="onReachTop" />
|
||||
</div>
|
||||
@@ -87,6 +89,9 @@ export default defineComponent({
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
},
|
||||
finalPrompt(): string {
|
||||
let content = '';
|
||||
if (this.config.references && this.config.references?.length > 0) {
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
@refresh="onGetApplication"
|
||||
@select="$store.dispatch('pika/setApplication', $event)"
|
||||
/>
|
||||
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
|
||||
@@ -76,6 +78,9 @@ export default defineComponent({
|
||||
application() {
|
||||
return this.$store.state.pika.application;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.pika.applications;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.pika.tasks;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
@refresh="onGetApplication"
|
||||
@select="$store.dispatch('qrart/setApplication', $event)"
|
||||
/>
|
||||
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||
</template>
|
||||
@@ -77,6 +79,9 @@ export default defineComponent({
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.qrart.tasks;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.qrart.applications;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:service="service"
|
||||
:need-apply="needApply"
|
||||
class="mb-4"
|
||||
@refresh="onGetApplication"
|
||||
@select="$store.dispatch('suno/setApplication', $event)"
|
||||
/>
|
||||
<recent-panel class="panel recent" @reach-top="onReachTop" />
|
||||
</template>
|
||||
@@ -82,6 +84,9 @@ export default defineComponent({
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.suno.tasks;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.suno.applications;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -29,6 +29,13 @@ export const setModelGroup = async ({ commit }: any, payload: IChatModelGroup):
|
||||
export const setApplication = async ({ commit }: any, payload: IApplication): Promise<void> => {
|
||||
console.debug('set application', payload);
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = async ({ commit }: any, payload: IApplication[]): Promise<void> => {
|
||||
console.debug('set applications', payload);
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const setService = async ({ commit }: any, payload: IService): Promise<void> => {
|
||||
@@ -93,6 +100,7 @@ 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);
|
||||
@@ -171,6 +179,7 @@ export default {
|
||||
setService,
|
||||
setCredential,
|
||||
setApplication,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setConversation,
|
||||
setConversations,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export default [
|
||||
'chat.application',
|
||||
'chat.applications',
|
||||
'chat.service',
|
||||
'chat.credential',
|
||||
'chat.conversations',
|
||||
|
||||
@@ -25,8 +25,14 @@ export const setService = async ({ commit }: any, payload: IService): Promise<vo
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
|
||||
export const setApplication = ({ commit }: any, payload: IApplication) => {
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = ({ commit }: any, payload: IApplication[]) => {
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
@@ -45,6 +51,7 @@ 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);
|
||||
@@ -165,6 +172,7 @@ export default {
|
||||
resetAll,
|
||||
setCredential,
|
||||
setConfig,
|
||||
setApplications,
|
||||
setApplication,
|
||||
getApplications,
|
||||
setTasks,
|
||||
|
||||
@@ -25,8 +25,14 @@ export const setService = async ({ commit }: any, payload: IService): Promise<vo
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
|
||||
export const setApplication = ({ commit }: any, payload: IApplication) => {
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = ({ commit }: any, payload: IApplication[]) => {
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
@@ -45,6 +51,7 @@ 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);
|
||||
@@ -166,6 +173,7 @@ export default {
|
||||
setCredential,
|
||||
setConfig,
|
||||
setApplication,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setTasks,
|
||||
setTasksItems,
|
||||
|
||||
@@ -25,8 +25,14 @@ export const setService = async ({ commit }: any, payload: IService): Promise<vo
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
|
||||
export const setApplication = ({ commit }: any, payload: IApplication) => {
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = ({ commit }: any, payload: IApplication[]) => {
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
@@ -45,6 +51,7 @@ 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);
|
||||
@@ -165,6 +172,7 @@ export default {
|
||||
setCredential,
|
||||
setConfig,
|
||||
setApplication,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setTasks,
|
||||
setTasksItems,
|
||||
|
||||
@@ -24,8 +24,14 @@ export const setService = async ({ commit }: any, payload: IService): Promise<vo
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
|
||||
export const setApplication = ({ commit }: any, payload: IApplication) => {
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = ({ commit }: any, payload: IApplication[]) => {
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
@@ -44,6 +50,7 @@ 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);
|
||||
@@ -150,6 +157,7 @@ export default {
|
||||
setCredential,
|
||||
setConfig,
|
||||
setApplication,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setTasks,
|
||||
setTasksItems,
|
||||
|
||||
@@ -2,15 +2,7 @@ import { applicationOperator, midjourneyOperator, serviceOperator } from '@/oper
|
||||
import { IMidjourneyState } from './models';
|
||||
import { ActionContext } from 'vuex';
|
||||
import { IRootState } from '../common/models';
|
||||
import {
|
||||
IApplication,
|
||||
IApplicationType,
|
||||
ICredential,
|
||||
IMidjourneyConfig,
|
||||
IMidjourneyTask,
|
||||
IMidjourneyTasksResponse,
|
||||
IService
|
||||
} from '@/models';
|
||||
import { IApplication, IApplicationType, ICredential, IMidjourneyConfig, IMidjourneyTask, IService } from '@/models';
|
||||
import { Status } from '@/models/common';
|
||||
import { MIDJOURNEY_SERVICE_ID } from '@/constants';
|
||||
import { mergeAndSortLists } from '@/utils/merge';
|
||||
@@ -45,8 +37,14 @@ export const setService = async ({ commit }: any, payload: IService): Promise<vo
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
|
||||
export const setApplication = ({ commit }: any, payload: IApplication) => {
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = ({ commit }: any, payload: IApplication[]) => {
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
@@ -65,6 +63,7 @@ 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);
|
||||
@@ -175,6 +174,7 @@ export default {
|
||||
setConfig,
|
||||
setMode,
|
||||
setApplication,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setTasks,
|
||||
getTasks
|
||||
|
||||
@@ -25,8 +25,14 @@ export const setService = async ({ commit }: any, payload: IService): Promise<vo
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
|
||||
export const setApplication = ({ commit }: any, payload: IApplication) => {
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = ({ commit }: any, payload: IApplication[]) => {
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
@@ -45,6 +51,7 @@ 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);
|
||||
@@ -166,6 +173,7 @@ export default {
|
||||
setCredential,
|
||||
setConfig,
|
||||
setApplication,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setTasks,
|
||||
setTasksItems,
|
||||
|
||||
@@ -25,8 +25,14 @@ export const setService = async ({ commit }: any, payload: IService): Promise<vo
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
|
||||
export const setApplication = ({ commit }: any, payload: IApplication) => {
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = ({ commit }: any, payload: IApplication[]) => {
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
@@ -45,6 +51,7 @@ 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);
|
||||
@@ -165,6 +172,7 @@ export default {
|
||||
setCredential,
|
||||
setConfig,
|
||||
setApplication,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setTasks,
|
||||
setTasksItems,
|
||||
|
||||
@@ -25,8 +25,14 @@ export const setService = async ({ commit }: any, payload: IService): Promise<vo
|
||||
commit('setService', payload);
|
||||
};
|
||||
|
||||
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
|
||||
export const setApplication = ({ commit }: any, payload: IApplication) => {
|
||||
commit('setApplication', payload);
|
||||
const credential = payload?.credentials?.find((credential) => credential?.host === window.location.origin);
|
||||
commit('setCredential', credential);
|
||||
};
|
||||
|
||||
export const setApplications = ({ commit }: any, payload: IApplication[]) => {
|
||||
commit('setApplications', payload);
|
||||
};
|
||||
|
||||
export const getApplications = async ({
|
||||
@@ -45,6 +51,7 @@ 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);
|
||||
@@ -170,6 +177,7 @@ export default {
|
||||
setCredential,
|
||||
setConfig,
|
||||
setApplication,
|
||||
setApplications,
|
||||
getApplications,
|
||||
setTasks,
|
||||
setTasksItems,
|
||||
|
||||
Reference in new issue
Block a user