ACL加载遮置

This commit is contained in:
许晓东
2021-10-09 15:21:19 +08:00
parent d4fdb739b9
commit 2baf8d093e
2 changed files with 249 additions and 206 deletions

View File

@@ -1,5 +1,6 @@
<template> <template>
<div class="content"> <div class="content">
<a-spin :spinning="loading">
<div class="acl"> <div class="acl">
<div id="components-form-acl-advanced-search"> <div id="components-form-acl-advanced-search">
<a-form <a-form
@@ -150,6 +151,7 @@
@addAuthDialog="closeAddAuthDialog" @addAuthDialog="closeAddAuthDialog"
></AddAuth> ></AddAuth>
</div> </div>
</a-spin>
</div> </div>
</template> </template>
@@ -193,6 +195,7 @@ export default {
resourceType: "", resourceType: "",
username: "", username: "",
}, },
loading: false,
}; };
}, },
methods: { methods: {
@@ -211,7 +214,7 @@ export default {
queryParam.resourceName = values.groupId; queryParam.resourceName = values.groupId;
} }
Object.assign(this.queryParam, queryParam); Object.assign(this.queryParam, queryParam);
getAclList(this.data, queryParam); this.getAclList();
}); });
}, },
@@ -225,7 +228,7 @@ export default {
closeUpdateUserDialog(data) { closeUpdateUserDialog(data) {
this.showUpdateUser = data.show; this.showUpdateUser = data.show;
if (data.ok) { if (data.ok) {
getAclList(this.data, this.queryParam); this.getAclList();
} }
}, },
onDeleteUser(row) { onDeleteUser(row) {
@@ -234,7 +237,7 @@ export default {
method: KafkaAclApi.deleteKafkaUser.method, method: KafkaAclApi.deleteKafkaUser.method,
data: { username: row.username }, data: { username: row.username },
}).then((res) => { }).then((res) => {
getAclList(this.data, this.queryParam); this.getAclList();
if (res.code == 0) { if (res.code == 0) {
this.$message.success(res.msg); this.$message.success(res.msg);
} else { } else {
@@ -278,40 +281,36 @@ export default {
}, },
closeManageProducerAuthDialog() { closeManageProducerAuthDialog() {
this.openManageProducerAuthDialog = false; this.openManageProducerAuthDialog = false;
getAclList(this.data, this.queryParam); this.getAclList();
}, },
closeManageConsumerAuthDialog() { closeManageConsumerAuthDialog() {
this.openManageConsumerAuthDialog = false; this.openManageConsumerAuthDialog = false;
getAclList(this.data, this.queryParam); this.getAclList();
}, },
closeAddAuthDialog(p) { closeAddAuthDialog(p) {
this.openAddAuthDialog = false; this.openAddAuthDialog = false;
if (p.refresh) { if (p.refresh) {
getAclList(this.data, this.queryParam); this.getAclList();
} }
}, },
closeAclDetailDialog(p) { closeAclDetailDialog(p) {
this.openAclDetailDialog = false; this.openAclDetailDialog = false;
if (p.refresh) { if (p.refresh) {
getAclList(this.data, this.queryParam); this.getAclList();
} }
}, },
closeUserDetailDialog() { closeUserDetailDialog() {
this.openUserDetailDialog = false; this.openUserDetailDialog = false;
}, },
}, getAclList() {
created() { this.loading = true;
getAclList(this.data, this.queryParam);
},
};
function getAclList(data, requestParameters) {
request({ request({
url: KafkaAclApi.getAclList.url, url: KafkaAclApi.getAclList.url,
method: KafkaAclApi.getAclList.method, method: KafkaAclApi.getAclList.method,
data: requestParameters, data: this.queryParam,
}).then((response) => { }).then((response) => {
data.splice(0, data.length); this.loading = false;
this.data.splice(0, this.data.length);
if (response.code != 0) { if (response.code != 0) {
notification.error({ notification.error({
message: response.msg, message: response.msg,
@@ -326,17 +325,55 @@ function getAclList(data, requestParameters) {
let groupList = Object.keys(v) let groupList = Object.keys(v)
.filter((e) => e.startsWith("GROUP")) .filter((e) => e.startsWith("GROUP"))
.map((e) => e.split("#")[1]); .map((e) => e.split("#")[1]);
data.push({ this.data.push({
key: k, key: k,
username: k, username: k,
topicList: topicList, topicList: topicList,
groupList: groupList, groupList: groupList,
user: response.data.map[k]["USER"], user: response.data.map[k]["USER"],
}); });
data.sort((a, b) => a.username.localeCompare(b.username)); this.data.sort((a, b) => a.username.localeCompare(b.username));
} }
}); });
} },
},
created() {
this.getAclList();
},
};
// function getAclList(data, requestParameters) {
// request({
// url: KafkaAclApi.getAclList.url,
// method: KafkaAclApi.getAclList.method,
// data: requestParameters,
// }).then((response) => {
// data.splice(0, data.length);
// if (response.code != 0) {
// notification.error({
// message: response.msg,
// });
// return;
// }
// for (let k in response.data.map) {
// let v = response.data.map[k];
// let topicList = Object.keys(v)
// .filter((e) => e.startsWith("TOPIC"))
// .map((e) => e.split("#")[1]);
// let groupList = Object.keys(v)
// .filter((e) => e.startsWith("GROUP"))
// .map((e) => e.split("#")[1]);
// data.push({
// key: k,
// username: k,
// topicList: topicList,
// groupList: groupList,
// user: response.data.map[k]["USER"],
// });
// data.sort((a, b) => a.username.localeCompare(b.username));
// }
// });
// }
const columns = [ const columns = [
{ {

View File

@@ -10,6 +10,7 @@
:footer="null" :footer="null"
:maskClosable="false" :maskClosable="false"
> >
<a-spin :spinning="loading">
<div> <div>
<a-table <a-table
:columns="columns" :columns="columns"
@@ -32,6 +33,7 @@
</a> </a>
</a-table> </a-table>
</div> </div>
</a-spin>
</a-modal> </a-modal>
</template> </template>
@@ -55,12 +57,14 @@ export default {
show: this.visible, show: this.visible,
data, data,
columns, columns,
loading: false,
}; };
}, },
watch: { watch: {
visible(v) { visible(v) {
this.show = v; this.show = v;
if (this.show) { if (this.show) {
this.data = [];
this.getAclDetail(); this.getAclDetail();
} }
}, },
@@ -70,12 +74,14 @@ export default {
this.$emit("aclDetailDialog", { refresh: true }); this.$emit("aclDetailDialog", { refresh: true });
}, },
getAclDetail() { getAclDetail() {
this.loading = true;
const api = KafkaAclApi.getAclDetailList; const api = KafkaAclApi.getAclDetailList;
request({ request({
url: api.url, url: api.url,
method: api.method, method: api.method,
data: this.selectDetail, data: this.selectDetail,
}).then((res) => { }).then((res) => {
this.loading = false;
if (res.code != 0) { if (res.code != 0) {
this.$message.error(res.msg); this.$message.error(res.msg);
} else { } else {