1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00
portainer/app/edge/views/edge-groups/editEdgeGroupView/editEdgeGroupViewController.js
cong meng 5316cca3de
fix(edge) EE-1733 cant edit edge groups (#5689)
* fix(edge) EE-1733 cant edit edge groups

* fix(edge) EE-1733 correct json names of a few edge objects

Co-authored-by: Simon Meng <simon.meng@portainer.io>
2021-09-21 17:41:27 +12:00

49 lines
1.4 KiB
JavaScript

export class EditEdgeGroupController {
/* @ngInject */
constructor(EdgeGroupService, GroupService, TagService, Notifications, $state, $async) {
this.EdgeGroupService = EdgeGroupService;
this.GroupService = GroupService;
this.TagService = TagService;
this.Notifications = Notifications;
this.$state = $state;
this.$async = $async;
this.state = {
actionInProgress: false,
loaded: false,
};
this.updateGroup = this.updateGroup.bind(this);
this.updateGroupAsync = this.updateGroupAsync.bind(this);
}
async $onInit() {
const [tags, endpointGroups, group] = await Promise.all([this.TagService.tags(), this.GroupService.groups(), this.EdgeGroupService.group(this.$state.params.groupId)]);
if (!group) {
this.Notifications.error('Failed to find edge group', {});
this.$state.go('edge.groups');
}
this.tags = tags;
this.endpointGroups = endpointGroups;
this.model = group;
this.state.loaded = true;
}
updateGroup() {
return this.$async(this.updateGroupAsync);
}
async updateGroupAsync() {
this.state.actionInProgress = true;
try {
await this.EdgeGroupService.update(this.model);
this.Notifications.success('Edge group successfully updated');
this.$state.go('edge.groups');
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to update edge group');
} finally {
this.state.actionInProgress = false;
}
}
}