mirror of
https://github.com/portainer/portainer.git
synced 2025-08-01 20:05:23 +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,42 @@
|
|||
import _ from 'lodash-es';
|
||||
|
||||
export class EdgeGroupsController {
|
||||
/* @ngInject */
|
||||
constructor($async, $state, EdgeGroupService, Notifications) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.EdgeGroupService = EdgeGroupService;
|
||||
this.Notifications = Notifications;
|
||||
|
||||
this.removeAction = this.removeAction.bind(this);
|
||||
this.removeActionAsync = this.removeActionAsync.bind(this);
|
||||
}
|
||||
|
||||
async $onInit() {
|
||||
try {
|
||||
this.items = await this.EdgeGroupService.groups();
|
||||
} catch (err) {
|
||||
this.items = [];
|
||||
this.Notifications.error('Failure', err, 'Unable to retrieve Edge groups');
|
||||
}
|
||||
}
|
||||
|
||||
removeAction(selectedItems) {
|
||||
return this.$async(this.removeActionAsync, selectedItems);
|
||||
}
|
||||
|
||||
async removeActionAsync(selectedItems) {
|
||||
for (let item of selectedItems) {
|
||||
try {
|
||||
await this.EdgeGroupService.remove(item.Id);
|
||||
|
||||
this.Notifications.success('Edge Group successfully removed', item.Name);
|
||||
_.remove(this.items, item);
|
||||
} catch (err) {
|
||||
this.Notifications.error('Failure', err, 'Unable to remove Edge Group');
|
||||
}
|
||||
}
|
||||
|
||||
this.$state.reload();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue