首选副本作为leader

This commit is contained in:
许晓东
2021-11-16 17:06:14 +08:00
parent a6ddb913f6
commit bcd62e84c1

View File

@@ -34,6 +34,24 @@
}} }}
</ol> </ol>
</ul> </ul>
<div slot="operation" slot-scope="record" v-show="!record.internal">
<a-popconfirm
:title="
'topic: ' +
topic +
',分区:' +
record.partition +
'确认选择第一个副本作为leader'
"
ok-text="确认"
cancel-text="取消"
@confirm="electPreferredLeader(record)"
>
<a-button size="small" href="javascript:;" class="operation-btn"
>首选副本作为leader
</a-button>
</a-popconfirm>
</div>
</a-table> </a-table>
</a-spin> </a-spin>
</div> </div>
@@ -42,7 +60,7 @@
<script> <script>
import request from "@/utils/request"; import request from "@/utils/request";
import { KafkaTopicApi } from "@/utils/api"; import { KafkaOpApi, KafkaTopicApi } from "@/utils/api";
import notification from "ant-design-vue/es/notification"; import notification from "ant-design-vue/es/notification";
export default { export default {
name: "PartitionInfo", name: "PartitionInfo",
@@ -94,6 +112,25 @@ export default {
this.data = []; this.data = [];
this.$emit("closePartitionInfoDialog", {}); this.$emit("closePartitionInfoDialog", {});
}, },
electPreferredLeader(record) {
this.loading = true;
request({
url: KafkaOpApi.electPreferredLeader.url,
method: KafkaOpApi.electPreferredLeader.method,
data: { topic: this.topic, partition: record.partition },
}).then((res) => {
this.loading = false;
if (res.code != 0) {
notification.error({
message: "error",
description: res.msg,
});
} else {
this.$message.success(res.msg);
this.getPartitionInfo();
}
});
},
}, },
}; };
@@ -135,6 +172,11 @@ const columns = [
dataIndex: "diff", dataIndex: "diff",
key: "diff", key: "diff",
}, },
{
title: "操作",
key: "operation",
scopedSlots: { customRender: "operation" },
},
]; ];
</script> </script>