add application
This commit is contained in:
1 parent
315ee355b8
commit
a5514e8e3e
4 files changed
+104
-17
No files matched your search
@@ -13,17 +13,31 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<div v-if="itemKey === 'api_key'">
|
||||
<el-popover
|
||||
placement="bottom"
|
||||
title="Title"
|
||||
:width="200"
|
||||
trigger="click"
|
||||
content="this is content, this is content, this is content"
|
||||
>
|
||||
<el-popover v-if="!isApplied" placement="bottom" :width="200" trigger="focus">
|
||||
<p>{{ $t('application.message.notApplied') }}</p>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="
|
||||
$router.push({
|
||||
name: 'service-detail',
|
||||
params: {
|
||||
id: service?.id
|
||||
}
|
||||
})
|
||||
"
|
||||
>{{ $t('common.button.apply') }}</el-button
|
||||
>
|
||||
<template #reference>
|
||||
<el-button class="m-2">Click to activate</el-button>
|
||||
<el-input v-model="value[itemKey?.toString()]" />
|
||||
</template>
|
||||
</el-popover>
|
||||
<el-select v-else v-model="value[itemKey?.toString()]" clearable :placeholder="$t('common.title.select')">
|
||||
<el-option :label="appliedApplication?.api_key" :value="appliedApplication?.api_key" class="select-option">
|
||||
<span class="select-option-main">{{ appliedApplication?.api_key }}</span>
|
||||
<span class="select-option-description">{{ $t('application.message.yourApplication') }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-select
|
||||
@@ -44,6 +58,9 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ISchema } from '@/operators/api/models';
|
||||
import { IService } from '@/operators/service/models';
|
||||
import { applicationOperator, IApplication, IApplicationListResponse } from '@/operators';
|
||||
import application from '@/i18n/zh/application';
|
||||
|
||||
interface IData {
|
||||
value: {
|
||||
@@ -57,6 +74,14 @@ export default defineComponent({
|
||||
schema: {
|
||||
type: Object as () => ISchema | undefined,
|
||||
required: true
|
||||
},
|
||||
service: {
|
||||
type: Object as () => IService | undefined,
|
||||
required: true
|
||||
},
|
||||
applications: {
|
||||
type: Array as () => IApplication[],
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['update:form'],
|
||||
@@ -65,6 +90,18 @@ export default defineComponent({
|
||||
value: {}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isApplied() {
|
||||
return this.applications.filter((application) => application.service?.id === this.service?.id).length > 0;
|
||||
},
|
||||
appliedApplication(): IApplication | undefined {
|
||||
const applications = this.applications.filter((application) => application.service?.id === this.service?.id);
|
||||
if (applications.length > 0) {
|
||||
return applications[0];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler() {
|
||||
@@ -146,4 +183,18 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
}
|
||||
.el-select-dropdown {
|
||||
.select-option {
|
||||
.select-option-main {
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
}
|
||||
.select-option-description {
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -18,15 +18,30 @@
|
||||
<el-divider />
|
||||
<div class="queries">
|
||||
<h2 class="title">{{ $t('api.entity.requestQueries') }}</h2>
|
||||
<api-form v-model:form="formValue.queries" :schema="api?.request?.queries" />
|
||||
<api-form
|
||||
v-model:form="formValue.queries"
|
||||
:schema="api?.request?.queries"
|
||||
:service="api?.service"
|
||||
:applications="applications"
|
||||
/>
|
||||
</div>
|
||||
<div class="headers">
|
||||
<h2 class="title">{{ $t('api.entity.requestHeaders') }}</h2>
|
||||
<api-form v-model:form="formValue.headers" :schema="api?.request?.headers" />
|
||||
<api-form
|
||||
v-model:form="formValue.headers"
|
||||
:schema="api?.request?.headers"
|
||||
:service="api?.service"
|
||||
:applications="applications"
|
||||
/>
|
||||
</div>
|
||||
<div class="body">
|
||||
<h2 class="title">{{ $t('api.entity.requestBody') }}</h2>
|
||||
<api-form v-model:form="formValue.body" :schema="api?.request?.body" />
|
||||
<api-form
|
||||
v-model:form="formValue.body"
|
||||
:schema="api?.request?.body"
|
||||
:service="api?.service"
|
||||
:applications="applications"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="api?.responses" class="responses">
|
||||
<h2 class="title">{{ $t('api.entity.response') }}</h2>
|
||||
@@ -41,9 +56,12 @@ import { IApi, IForm } from '@/operators/api/models';
|
||||
import ApiForm from './Form.vue';
|
||||
import ApiResult from './Result.vue';
|
||||
import urlJoin from 'url-join';
|
||||
import { applicationOperator } from '@/operators/application/operator';
|
||||
import { IApplication, IApplicationListResponse } from '@/operators/application/models';
|
||||
|
||||
export interface IData {
|
||||
formValue: IForm | undefined;
|
||||
formValue: IForm;
|
||||
applications: IApplication[];
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
@@ -67,9 +85,10 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
emits: ['update:form'],
|
||||
data() {
|
||||
data(): IData {
|
||||
return {
|
||||
formValue: this.form
|
||||
formValue: this.form || {},
|
||||
applications: []
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -80,8 +99,20 @@ export default defineComponent({
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getApplications();
|
||||
},
|
||||
methods: {
|
||||
urlJoin
|
||||
urlJoin,
|
||||
getApplications() {
|
||||
applicationOperator
|
||||
.getAll({
|
||||
user_id: this.$store.getters.user.id
|
||||
})
|
||||
.then(({ data: data }: { data: IApplicationListResponse }) => {
|
||||
this.applications = data.items;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
export default {
|
||||
alreadyApplied: '已经申请过该服务,请到控制台查看',
|
||||
applySuccessfully: '申请成功,即将跳转到控制台'
|
||||
applySuccessfully: '申请成功,即将跳转到控制台',
|
||||
notApplied: '你尚未申请过该服务,请先申请该服务之后使用',
|
||||
yourApplication: '你的申请'
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
import { IService } from '../service';
|
||||
|
||||
export interface IForm {
|
||||
queries?: {
|
||||
[key: string]: string;
|
||||
@@ -54,7 +56,8 @@ export interface IApi {
|
||||
responses: IResponse[];
|
||||
response_ids: string[];
|
||||
is_free?: boolean;
|
||||
service?: string;
|
||||
service?: IService;
|
||||
service_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user