mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
refactor(edge-compute): enforce es6 good practices (#3961)
* refactor(edge-groups): use es6 imports * refactor(edge-jobs): es6 imports * refactor(edge-stacks): use es6 imports * refactor(edge-compute): use es6 imports in components * refactor(edge-compute): use named imports
This commit is contained in:
parent
af6bea5acc
commit
42aa8ceb00
52 changed files with 99 additions and 115 deletions
|
@ -0,0 +1,51 @@
|
|||
export class EditEdgeGroupController {
|
||||
/* @ngInject */
|
||||
constructor(EdgeGroupService, GroupService, TagService, Notifications, $state, $async, EndpointService, EndpointHelper) {
|
||||
this.EdgeGroupService = EdgeGroupService;
|
||||
this.GroupService = GroupService;
|
||||
this.TagService = TagService;
|
||||
this.Notifications = Notifications;
|
||||
this.$state = $state;
|
||||
this.$async = $async;
|
||||
this.EndpointService = EndpointService;
|
||||
this.EndpointHelper = EndpointHelper;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue