mirror of
https://github.com/portainer/portainer.git
synced 2025-08-06 22:35:23 +02:00
refactor(edge/groups): migrate view to react [EE-4683] (#10592)
This commit is contained in:
parent
1f2f4525e3
commit
99b39da03d
18 changed files with 199 additions and 228 deletions
|
@ -1,7 +0,0 @@
|
|||
<page-header title="'Edge Groups'" breadcrumbs="['Edge Groups']" reload="true"> </page-header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<edge-groups-datatable title-icon="dice-4" table-key="EdgeGroups" order-by="Name" dataset="$ctrl.items" remove-action="$ctrl.removeAction"></edge-groups-datatable>
|
||||
</div>
|
||||
</div>
|
|
@ -1,47 +0,0 @@
|
|||
import _ from 'lodash-es';
|
||||
import { confirmDelete } from '@@/modals/confirm';
|
||||
|
||||
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) {
|
||||
if (!(await confirmDelete('Do you want to remove the selected Edge Group(s)?'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
import angular from 'angular';
|
||||
|
||||
import { EdgeGroupsController } from './edgeGroupsViewController';
|
||||
|
||||
angular.module('portainer.edge').component('edgeGroupsView', {
|
||||
templateUrl: './edgeGroupsView.html',
|
||||
controller: EdgeGroupsController,
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue