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,48 @@
|
|||
import _ from 'lodash-es';
|
||||
|
||||
export class EdgeStacksViewController {
|
||||
constructor($state, Notifications, EdgeStackService, $scope, $async) {
|
||||
this.$state = $state;
|
||||
this.Notifications = Notifications;
|
||||
this.EdgeStackService = EdgeStackService;
|
||||
this.$scope = $scope;
|
||||
this.$async = $async;
|
||||
|
||||
this.stacks = undefined;
|
||||
|
||||
this.getStacks = this.getStacks.bind(this);
|
||||
this.removeAction = this.removeAction.bind(this);
|
||||
this.removeActionAsync = this.removeActionAsync.bind(this);
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.getStacks();
|
||||
}
|
||||
|
||||
removeAction(stacks) {
|
||||
return this.$async(this.removeActionAsync, stacks);
|
||||
}
|
||||
|
||||
async removeActionAsync(stacks) {
|
||||
for (let stack of stacks) {
|
||||
try {
|
||||
await this.EdgeStackService.remove(stack.Id);
|
||||
this.Notifications.success('Stack successfully removed', stack.Name);
|
||||
_.remove(this.stacks, stack);
|
||||
} catch (err) {
|
||||
this.Notifications.error('Failure', err, 'Unable to remove stack ' + stack.Name);
|
||||
}
|
||||
}
|
||||
|
||||
this.$state.reload();
|
||||
}
|
||||
|
||||
async getStacks() {
|
||||
try {
|
||||
this.stacks = await this.EdgeStackService.stacks();
|
||||
} catch (err) {
|
||||
this.stacks = [];
|
||||
this.Notifications.error('Failure', err, 'Unable to retrieve stacks');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue