diff --git a/app/edge/__module.js b/app/edge/__module.js index be1da9d61..d507ed391 100644 --- a/app/edge/__module.js +++ b/app/edge/__module.js @@ -35,7 +35,7 @@ angular url: '/new', views: { 'content@': { - component: 'createEdgeGroupView', + component: 'edgeGroupsCreateView', }, }, }; @@ -45,7 +45,7 @@ angular url: '/:groupId', views: { 'content@': { - component: 'editEdgeGroupView', + component: 'edgeGroupsItemView', }, }, }; diff --git a/app/edge/components/group-form/groupForm.html b/app/edge/components/group-form/groupForm.html deleted file mode 100644 index 9bd0c0ffd..000000000 --- a/app/edge/components/group-form/groupForm.html +++ /dev/null @@ -1,79 +0,0 @@ -
diff --git a/app/edge/components/group-form/groupFormController.js b/app/edge/components/group-form/groupFormController.js deleted file mode 100644 index f668c5877..000000000 --- a/app/edge/components/group-form/groupFormController.js +++ /dev/null @@ -1,86 +0,0 @@ -import { confirmDestructive } from '@@/modals/confirm'; -import { EdgeTypes } from '@/react/portainer/environments/types'; -import { buildConfirmButton } from '@@/modals/utils'; -import { tagOptions } from '@/react/edge/edge-groups/CreateView/tag-options'; -import { groupTypeOptions } from '@/react/edge/edge-groups/CreateView/group-type-options'; - -export class EdgeGroupFormController { - /* @ngInject */ - constructor($async, $scope) { - this.$async = $async; - this.$scope = $scope; - - this.groupTypeOptions = groupTypeOptions; - this.tagOptions = tagOptions; - - this.dynamicQuery = { - types: EdgeTypes, - tagIds: [], - tagsPartialMatch: false, - }; - - this.onChangeEnvironments = this.onChangeEnvironments.bind(this); - this.onChangeTags = this.onChangeTags.bind(this); - this.onChangeDynamic = this.onChangeDynamic.bind(this); - this.onChangeModel = this.onChangeModel.bind(this); - this.onChangePartialMatch = this.onChangePartialMatch.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); - - $scope.$watch( - () => this.model, - () => { - if (this.model.Dynamic) { - this.dynamicQuery = { - types: EdgeTypes, - tagIds: this.model.TagIds, - tagsPartialMatch: this.model.PartialMatch, - }; - } - }, - true - ); - } - - onChangeModel(model) { - return this.$scope.$evalAsync(() => { - this.model = { - ...this.model, - ...model, - }; - }); - } - - onChangePartialMatch(value) { - return this.onChangeModel({ PartialMatch: value }); - } - - onChangeDynamic(value) { - this.onChangeModel({ Dynamic: value }); - } - - onChangeTags(value) { - this.onChangeModel({ TagIds: value }); - } - - onChangeEnvironments(value, meta) { - return this.$async(async () => { - if (meta.type === 'remove' && this.pageType === 'edit') { - const confirmed = await confirmDestructive({ - title: 'Confirm action', - message: 'Removing the environment from this group will remove its corresponding edge stacks', - confirmButton: buildConfirmButton('Confirm'), - }); - - if (!confirmed) { - return; - } - } - - this.onChangeModel({ Endpoints: value }); - }); - } - - handleSubmit() { - this.formAction(this.model); - } -} diff --git a/app/edge/components/group-form/index.js b/app/edge/components/group-form/index.js deleted file mode 100644 index 23ed1bbd0..000000000 --- a/app/edge/components/group-form/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import angular from 'angular'; - -import { EdgeGroupFormController } from './groupFormController'; - -angular.module('portainer.edge').component('edgeGroupForm', { - templateUrl: './groupForm.html', - controller: EdgeGroupFormController, - bindings: { - model: '<', - formActionLabel: '@', - formAction: '<', - actionInProgress: '<', - loaded: '<', - pageType: '@', - }, -}); diff --git a/app/edge/react/components/index.ts b/app/edge/react/components/index.ts index d552e1a86..916005936 100644 --- a/app/edge/react/components/index.ts +++ b/app/edge/react/components/index.ts @@ -1,14 +1,13 @@ import angular from 'angular'; -import { EdgeGroupsSelector } from '@/react/edge/edge-stacks/components/EdgeGroupsSelector'; import { r2a } from '@/react-tools/react2angular'; import { withReactQuery } from '@/react-tools/withReactQuery'; +import { withUIRouter } from '@/react-tools/withUIRouter'; +import { AssociatedEdgeEnvironmentsSelector } from '@/react/edge/components/AssociatedEdgeEnvironmentsSelector'; +import { EdgeAsyncIntervalsForm } from '@/react/edge/components/EdgeAsyncIntervalsForm'; import { EdgeCheckinIntervalField } from '@/react/edge/components/EdgeCheckInIntervalField'; import { EdgeScriptForm } from '@/react/edge/components/EdgeScriptForm'; -import { EdgeAsyncIntervalsForm } from '@/react/edge/components/EdgeAsyncIntervalsForm'; -import { withUIRouter } from '@/react-tools/withUIRouter'; -import { EdgeGroupAssociationTable } from '@/react/edge/components/EdgeGroupAssociationTable'; -import { AssociatedEdgeEnvironmentsSelector } from '@/react/edge/components/AssociatedEdgeEnvironmentsSelector'; +import { EdgeGroupsSelector } from '@/react/edge/edge-stacks/components/EdgeGroupsSelector'; import { edgeJobsModule } from './edge-jobs'; @@ -57,20 +56,12 @@ const ngModule = angular 'fieldSettings', ]) ) - .component( - 'edgeGroupAssociationTable', - r2a(withReactQuery(EdgeGroupAssociationTable), [ - 'onClickRow', - 'query', - 'title', - 'data-cy', - ]) - ) .component( 'associatedEdgeEnvironmentsSelector', r2a(withReactQuery(AssociatedEdgeEnvironmentsSelector), [ 'onChange', 'value', + 'error', ]) ); diff --git a/app/edge/react/views/groups.ts b/app/edge/react/views/groups.ts new file mode 100644 index 000000000..deb51b0f0 --- /dev/null +++ b/app/edge/react/views/groups.ts @@ -0,0 +1,20 @@ +import angular from 'angular'; + +import { r2a } from '@/react-tools/react2angular'; +import { withCurrentUser } from '@/react-tools/withCurrentUser'; +import { withUIRouter } from '@/react-tools/withUIRouter'; +import { ListView } from '@/react/edge/edge-groups/ListView'; +import { CreateView } from '@/react/edge/edge-groups/CreateView/CreateView'; +import { ItemView } from '@/react/edge/edge-groups/ItemView/ItemView'; + +export const groupsModule = angular + .module('portainer.edge.react.views.groups', []) + .component('edgeGroupsView', r2a(withUIRouter(withCurrentUser(ListView)), [])) + .component( + 'edgeGroupsCreateView', + r2a(withUIRouter(withCurrentUser(CreateView)), []) + ) + .component( + 'edgeGroupsItemView', + r2a(withUIRouter(withCurrentUser(ItemView)), []) + ).name; diff --git a/app/edge/react/views/index.ts b/app/edge/react/views/index.ts index e4f010382..9b35040eb 100644 --- a/app/edge/react/views/index.ts +++ b/app/edge/react/views/index.ts @@ -5,23 +5,20 @@ import { withCurrentUser } from '@/react-tools/withCurrentUser'; import { withReactQuery } from '@/react-tools/withReactQuery'; import { withUIRouter } from '@/react-tools/withUIRouter'; import { WaitingRoomView } from '@/react/edge/edge-devices/WaitingRoomView'; -import { ListView as EdgeGroupsListView } from '@/react/edge/edge-groups/ListView'; import { templatesModule } from './templates'; import { jobsModule } from './jobs'; import { stacksModule } from './edge-stacks'; +import { groupsModule } from './groups'; export const viewsModule = angular .module('portainer.edge.react.views', [ templatesModule, jobsModule, stacksModule, + groupsModule, ]) .component( 'waitingRoomView', r2a(withUIRouter(withReactQuery(withCurrentUser(WaitingRoomView))), []) - ) - .component( - 'edgeGroupsView', - r2a(withUIRouter(withCurrentUser(EdgeGroupsListView)), []) ).name; diff --git a/app/edge/rest/edge-groups.js b/app/edge/rest/edge-groups.js index 676b10281..9c0a6cbb6 100644 --- a/app/edge/rest/edge-groups.js +++ b/app/edge/rest/edge-groups.js @@ -5,11 +5,7 @@ angular.module('portainer.edge').factory('EdgeGroups', function EdgeGroupsFactor API_ENDPOINT_EDGE_GROUPS + '/:id/:action', {}, { - create: { method: 'POST', ignoreLoadingBar: true }, query: { method: 'GET', isArray: true }, - get: { method: 'GET', params: { id: '@id' } }, - update: { method: 'PUT', params: { id: '@Id' } }, - remove: { method: 'DELETE', params: { id: '@id' } }, } ); }); diff --git a/app/edge/services/edge-group.js b/app/edge/services/edge-group.js index 48a27f377..62f87db71 100644 --- a/app/edge/services/edge-group.js +++ b/app/edge/services/edge-group.js @@ -3,25 +3,9 @@ import angular from 'angular'; angular.module('portainer.edge').factory('EdgeGroupService', function EdgeGroupServiceFactory(EdgeGroups) { var service = {}; - service.group = function group(groupId) { - return EdgeGroups.get({ id: groupId }).$promise; - }; - service.groups = function groups() { return EdgeGroups.query({}).$promise; }; - service.remove = function remove(groupId) { - return EdgeGroups.remove({ id: groupId }).$promise; - }; - - service.create = function create(group) { - return EdgeGroups.create(group).$promise; - }; - - service.update = function update(group) { - return EdgeGroups.update(group).$promise; - }; - return service; }); diff --git a/app/edge/views/edge-groups/createEdgeGroupView/createEdgeGroupView.html b/app/edge/views/edge-groups/createEdgeGroupView/createEdgeGroupView.html deleted file mode 100644 index 883cceaa1..000000000 --- a/app/edge/views/edge-groups/createEdgeGroupView/createEdgeGroupView.html +++ /dev/null @@ -1,18 +0,0 @@ -