新建订阅
This commit is contained in:
@@ -57,6 +57,10 @@ export const KafkaConfigApi = {
|
||||
};
|
||||
|
||||
export const KafkaTopicApi = {
|
||||
getTopicNameList: {
|
||||
url: "/topic",
|
||||
method: "get",
|
||||
},
|
||||
getTopicList: {
|
||||
url: "/topic/list",
|
||||
method: "get",
|
||||
@@ -96,6 +100,10 @@ export const KafkaConsumerApi = {
|
||||
url: "/consumer/detail",
|
||||
method: "get",
|
||||
},
|
||||
addSubscription: {
|
||||
url: "/consumer/subscription",
|
||||
method: "post",
|
||||
},
|
||||
};
|
||||
|
||||
export const KafkaClusterApi = {
|
||||
|
||||
135
ui/src/views/group/AddSupscription.vue
Normal file
135
ui/src/views/group/AddSupscription.vue
Normal file
@@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<a-modal
|
||||
title="新增订阅关系"
|
||||
:visible="show"
|
||||
:width="800"
|
||||
:mask="false"
|
||||
:destroyOnClose="true"
|
||||
:footer="null"
|
||||
:maskClosable="false"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<div>
|
||||
<a-spin :spinning="loading">
|
||||
<a-form
|
||||
:form="form"
|
||||
:label-col="{ span: 5 }"
|
||||
:wrapper-col="{ span: 12 }"
|
||||
@submit="handleSubmit"
|
||||
>
|
||||
<a-form-item label="消费组">
|
||||
<a-input
|
||||
v-decorator="[
|
||||
'groupId',
|
||||
{ rules: [{ required: true, message: '输入消费组名称!' }] },
|
||||
]"
|
||||
placeholder="groupId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="topic">
|
||||
<a-select
|
||||
show-search
|
||||
option-filter-prop="children"
|
||||
v-decorator="[
|
||||
'topic',
|
||||
{ rules: [{ required: true, message: '请选择一个topic!' }] },
|
||||
]"
|
||||
placeholder="请选择一个topic"
|
||||
>
|
||||
<a-select-option v-for="v in topicList" :key="v" :value="v">
|
||||
{{ v }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item :wrapper-col="{ span: 12, offset: 5 }">
|
||||
<a-button type="primary" html-type="submit"> 提交 </a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</div>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from "@/utils/request";
|
||||
import { KafkaTopicApi, KafkaConsumerApi } from "@/utils/api";
|
||||
import notification from "ant-design-vue/es/notification";
|
||||
export default {
|
||||
name: "AddSubscription",
|
||||
props: {
|
||||
topic: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
show: this.visible,
|
||||
data: [],
|
||||
loading: false,
|
||||
form: this.$form.createForm(this, { name: "coordinated" }),
|
||||
topicList: [],
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
visible(v) {
|
||||
this.show = v;
|
||||
if (this.show) {
|
||||
this.getTopicNameList();
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getTopicNameList() {
|
||||
request({
|
||||
url: KafkaTopicApi.getTopicNameList.url,
|
||||
method: KafkaTopicApi.getTopicNameList.method,
|
||||
}).then((res) => {
|
||||
if (res.code == 0) {
|
||||
this.topicList = res.data;
|
||||
} else {
|
||||
notification.error({
|
||||
message: "error",
|
||||
description: res.msg,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.loading = true;
|
||||
request({
|
||||
url: KafkaConsumerApi.addSubscription.url,
|
||||
method: KafkaConsumerApi.addSubscription.method,
|
||||
data: values,
|
||||
}).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.code == 0) {
|
||||
this.$message.success(res.msg);
|
||||
this.$emit("closeAddSubscriptionDialog", { refresh: true });
|
||||
} else {
|
||||
notification.error({
|
||||
message: "error",
|
||||
description: res.msg,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
handleCancel() {
|
||||
this.data = [];
|
||||
this.$emit("closeAddSubscriptionDialog", { refresh: false });
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -61,7 +61,9 @@
|
||||
</a-form>
|
||||
</div>
|
||||
<div class="operation-row-button">
|
||||
<!-- <a-button type="primary" @click="handleReset">新增/更新</a-button>-->
|
||||
<a-button type="primary" @click="openAddSubscriptionDialog"
|
||||
>新增订阅</a-button
|
||||
>
|
||||
</div>
|
||||
<a-table
|
||||
:columns="columns"
|
||||
@@ -111,6 +113,11 @@
|
||||
@closeConsumerDetailDialog="closeConsumerDetailDialog"
|
||||
>
|
||||
</ConsumerDetail>
|
||||
<AddSupscription
|
||||
:visible="showAddSubscriptionDialog"
|
||||
@closeAddSubscriptionDialog="closeAddSubscriptionDialog"
|
||||
>
|
||||
</AddSupscription>
|
||||
</div>
|
||||
</a-spin>
|
||||
</div>
|
||||
@@ -122,10 +129,11 @@ import { KafkaConsumerApi } from "@/utils/api";
|
||||
import notification from "ant-design-vue/es/notification";
|
||||
import Member from "@/views/group/Member";
|
||||
import ConsumerDetail from "@/views/group/ConsumerDetail";
|
||||
import AddSupscription from "@/views/group/AddSupscription";
|
||||
|
||||
export default {
|
||||
name: "ConsumerGroup",
|
||||
components: { Member, ConsumerDetail },
|
||||
components: { Member, ConsumerDetail, AddSupscription },
|
||||
data() {
|
||||
return {
|
||||
queryParam: {},
|
||||
@@ -145,6 +153,7 @@ export default {
|
||||
loading: false,
|
||||
showConsumerGroupDialog: false,
|
||||
showConsumerDetailDialog: false,
|
||||
showAddSubscriptionDialog: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
@@ -201,6 +210,12 @@ export default {
|
||||
closeConsumerDetailDialog() {
|
||||
this.showConsumerDetailDialog = false;
|
||||
},
|
||||
openAddSubscriptionDialog() {
|
||||
this.showAddSubscriptionDialog = true;
|
||||
},
|
||||
closeAddSubscriptionDialog() {
|
||||
this.showAddSubscriptionDialog = false;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getConsumerGroupList();
|
||||
|
||||
@@ -100,15 +100,9 @@ export default {
|
||||
watch: {
|
||||
visible(v) {
|
||||
this.show = v;
|
||||
if (this.show) {
|
||||
this.getPartitionInfo();
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getPartitionInfo() {
|
||||
this.loading = false;
|
||||
},
|
||||
handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
this.form.validateFields((err, values) => {
|
||||
|
||||
Reference in New Issue
Block a user