mirror of
https://github.com/portainer/portainer.git
synced 2025-08-09 07:45:22 +02:00
fix(groups): update endpoint lists on change EE-3841
This commit is contained in:
parent
79822e1d3b
commit
00d32ffc61
1 changed files with 14 additions and 2 deletions
|
@ -40,10 +40,15 @@ class GroupFormController {
|
||||||
},
|
},
|
||||||
allowCreateTag: this.Authentication.isAdmin(),
|
allowCreateTag: this.Authentication.isAdmin(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.associatedEndpoints = [];
|
||||||
|
this.availableEndpoints = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
associateEndpoint(endpoint) {
|
associateEndpoint(endpoint) {
|
||||||
if (this.pageType === 'create' && !_.includes(this.associatedEndpoints, endpoint)) {
|
if (this.pageType === 'create' && !_.includes(this.associatedEndpoints, endpoint)) {
|
||||||
this.associatedEndpoints.push(endpoint);
|
this.associatedEndpoints.push(endpoint);
|
||||||
|
this.reloadEndpoints();
|
||||||
} else if (this.pageType === 'edit') {
|
} else if (this.pageType === 'edit') {
|
||||||
this.GroupService.addEndpoint(this.model.Id, endpoint)
|
this.GroupService.addEndpoint(this.model.Id, endpoint)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -57,6 +62,7 @@ class GroupFormController {
|
||||||
dissociateEndpoint(endpoint) {
|
dissociateEndpoint(endpoint) {
|
||||||
if (this.pageType === 'create') {
|
if (this.pageType === 'create') {
|
||||||
_.remove(this.associatedEndpoints, (item) => item.Id === endpoint.Id);
|
_.remove(this.associatedEndpoints, (item) => item.Id === endpoint.Id);
|
||||||
|
this.reloadEndpoints();
|
||||||
} else if (this.pageType === 'edit') {
|
} else if (this.pageType === 'edit') {
|
||||||
this.GroupService.removeEndpoint(this.model.Id, endpoint.Id)
|
this.GroupService.removeEndpoint(this.model.Id, endpoint.Id)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -67,9 +73,13 @@ class GroupFormController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadTablesContent() {
|
reloadEndpoints() {
|
||||||
this.getPaginatedEndpointsByGroup(this.pageType, 'available');
|
this.getPaginatedEndpointsByGroup(this.pageType, 'available');
|
||||||
this.getPaginatedEndpointsByGroup(this.pageType, 'associated');
|
this.getPaginatedEndpointsByGroup(this.pageType, 'associated');
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadTablesContent() {
|
||||||
|
this.reloadEndpoints();
|
||||||
this.GroupService.group(this.model.Id).then((data) => {
|
this.GroupService.group(this.model.Id).then((data) => {
|
||||||
this.model = data;
|
this.model = data;
|
||||||
});
|
});
|
||||||
|
@ -82,7 +92,9 @@ class GroupFormController {
|
||||||
const context = this.state.available;
|
const context = this.state.available;
|
||||||
const start = (context.pageNumber - 1) * context.limit + 1;
|
const start = (context.pageNumber - 1) * context.limit + 1;
|
||||||
const data = await endpointsByGroup(1, start, context.limit, { search: context.filter });
|
const data = await endpointsByGroup(1, start, context.limit, { search: context.filter });
|
||||||
this.availableEndpoints = data.value;
|
this.availableEndpoints = data.value.filter(
|
||||||
|
(availableEndpoint) => !this.associatedEndpoints.map((associatedEndpoint) => associatedEndpoint.Id).includes(availableEndpoint.Id)
|
||||||
|
);
|
||||||
this.state.available.totalCount = data.totalCount;
|
this.state.available.totalCount = data.totalCount;
|
||||||
} else if (tableType === 'associated' && pageType === 'edit') {
|
} else if (tableType === 'associated' && pageType === 'edit') {
|
||||||
const groupId = this.model.Id ? this.model.Id : 1;
|
const groupId = this.model.Id ? this.model.Id : 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue